cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.UnsatisfiedLinkError: getVersion()Ljava/lang/String; Windows

Former Member
0 Kudos

Hi,

We are getting this error java.lang.UnsatisfiedLinkError when application tries to make a native call to getVersion(). From my research so far what I got that if we do not have the .dll file place correctly or if there is an issue in loading the file we get this error.

But in this case we see the libraries getting loaded fine but when tries to call this method we are getting the error.

Note: we have placed the dll's under C:\windows\system32

Code snippet:

-


public class SSO2Test{

public static String SECLIBRARY;

public static String SSO2TICKETLIBRARY = "sapssoext";

static {

if (System.getProperty("os.name").startsWith("Win")) {

SECLIBRARY = "sapsecu.dll";

} else {

SECLIBRARY = "libsapsecu.so";

}

try {

System.loadLibrary(SSO2TICKETLIBRARY);

System.out.println("SAPSSOEXT loaded.");

} catch (Throwable e) {

System.out.println("Error during initialization of SSO2TICKET:\n"

+ e.getMessage());

}

}

public static native synchronized String getVersion();

public static void main(String[] args) throws Exception {

try {

System.out.println("Start SSO2TICKET main");

System.out.println("****** test version*******");

String version = SSO2Test.getVersion();

System.out.println("Version of SAPSSOEXT: " + version);

// MORE CODE

} catch (Exception e) {

System.out.println(e);

} catch (Throwable te) {

System.out.println(te);

}

}

}

Output:

SAPSSOEXT loaded.

Start SSO2TICKET main

            • test version*******

java.lang.UnsatisfiedLinkError: SSO2Test.getVersion()Ljava/lang/String;

-


Looking at the output its clear that loading the library part is fine. The error is getting thrown when trying to call the method.

Kindly provide assistance to resolve the same.

Thank You.

Edited by: abhijeet21 on Dec 29, 2009 9:56 PM

Edited by: abhijeet21 on Dec 29, 2009 9:57 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

so you have actually implemented a getVersion() method for your class in "native" code and placed that into a DLL that is now in the system32 directory? Please note that any native method needs a corresponding implementation that can be called. I suspect you might not have that and just revamped the sample coding from the SSOEXTLIB. There you find the call:


SSO2Ticket.getVersion();

Have you tried running the actual Java sample that is supplied with the SSOEXTLIB? Do you get any errors? Note that the libraries should be placed in a directory which is included in the PATH environment variable. In your case this should be ok, because system32 should be in the path.

Cheers, harald

Former Member
0 Kudos

Harald,

Thanks for the reply. Please bear with me on the native programming and my SAP knowledge as I am bit new to this world.

Help me understand this.. we did try the sample code which has the class name as SSO2Ticket.java and it works fine. So does that mean that if we try to load/use this library from a different class name we will have to modify the dll file accordingly.

And if this is true what should be the ideal way to use this library. Would it work fine If we keep the class name same when we implement this in our application?

Thank for the assistance in this regard.

Former Member
0 Kudos

Unfortunately I don't have any experience with that SAPSSOEXT library. I don't have an SSO system to do a quick check, so I'm probably of not much help (just spotted the problem with the native JNI reference and threw a quick comment). Please try the example mentioned in this [link|http://trick77.com/2008/02/07/validating-sap-logon-tickets-with-java/], which shows how to possibly use it.

I generally would say either you utilize the class SSO2Ticket as provided by SAP and simply add/modify methods that you need. Alternatively you could follow the sample code for class TicketSample from this [link|http://trick77.com/2008/02/07/validating-sap-logon-tickets-with-java/], which is a bit more detailed.

Due to weird formatting you'll have to edit the Java code a bit to get it to compile. When doing a quick test I used this example, but removed the package statements and also removed the package statement from the import for the SSO2Ticket class (since the class provided by SAP doesn't have any package statement). I then also had the problem that the init method of SSO2Ticket was declared private, so I couldn't call it from that other class TicketSample. Therefore I changed visibility from private to public and recompiled SSO2Ticket. It looked like I could then use it as intended from TicketSample.

Note though that I had to cheat a bit, since due to lack of an SSO system I only moved the SSO2Ticket.init() call to the very beginning of the TicketSample.main method and checked if the loading of the library seemed to work (I know, poor test, but didn't have much of a choice).

Hope this helps at least a little bit, cheers, harald

Former Member
0 Kudos

Thanks Harald. We were able to resolve the issue. First we renamed the class as SSO2Ticket.java but it didn't resolve the issue but when we kept this file inside package structure com.mysap.sso , system was able to locate the native methods correctly.

So the basic point here is to keep the class name and package structure as provided. The link from your post [link|http://trick77.com/2008/02/07/validating-sap-logon-tickets-with-java/] did explain about this.

Thank You.

Abhijeet-K
Active Participant
0 Kudos

Thanks to you and Former Member I could get through this tricky native coding part. Spent one full day fruitlessly because I had changed the name.

Answers (0)