cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.UnsatisfiedLinkError when loading libaries

Former Member
0 Kudos

Hi,

I coded an ejb, in which I want to call funtionality coming from a dll via JNI.

In order to achieve it I copied the libary 'XXX.dll' to the windows directory system32

and call in my ejb : System.loadLibary("XXX").

The following exception occured:

javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: no XXX in java.library.path

Can anybody help me by saying

1) where to put the .dll and what path to set in calling System.loadLibary(...)

3) or even where and how to set the java.libary.path variable (Instance Template via configtool?)

Honour and points are garanteed.

Jens

View Entire Topic
former_member193769
Active Contributor
0 Kudos

Hi,

Try setting the path in system environmental variables.

Thanking You,

Gopal

Former Member
0 Kudos

Hi Gopal,

in the meantime I get an answer from SAP.

They provided conserns using JNI in the EJB context.

Therefore the question

1) Did you tried using JNI from an ejb?

2) if yes, I believe the system environmental variables will not help. These settings are VM specific. Please only post, what you can assure and not what you assume.

Thanks,

Jens

former_member193769
Active Contributor
0 Kudos

Hi,

I have done similar to this in different environment.

I have created an ejb that creates a wrapper class that instantiates the JNI class

It worked in JBoss and in WebSphere.

sending to virtual machine to a repository DLL function using a Java Native Interface (JNI) call.

I said to pass the path in server.

Sorry if i misunderstood your development.

But i don't think a small assumption is that much dangerous to your great development.

I think I can post what I assume. Trying that is your wish.

Thanks,

Gopal.

Former Member
0 Kudos

Hi,

I opened an OSS and will post the answer, if SAP helps.

In the meantime it would be great, if you could explain your solution a little bit more in detail.

You adviced setting the java-libary-path in the system environment variables.

Where and how this should this be done? configtool?

And how must the coding for the libary loading (System.loadLibary()) look like?

If you could post one simple example - this would be great.

Thanks in advance for your explanation.

Jens

former_member193769
Active Contributor
0 Kudos

Hi,

Check This,

File f = new File("C:");

System.out.println(f + " \t" + f.exists());

f = new File(f, "sampleDLL2");

System.out.println(f + " \t" + f.exists());

System.load( f.toString() );

When the library can not be found, you get a java.lang.UnsatisfiedLinkError with the message "no library in java.library.path". To solve this, move the library in one of the directories specified by java.library.path or alter the property so that it points to the directory containing your library. You can print this property with the following code:

1: System.out.println(System.getProperty("java.library.path"));

Another possibility when things do not work is when the DLL can be found, but the methods can not. A DLL exports functions according to specific names an calling conventions. When your compiler is not configured the right way your methods may get anther name than they should be. To solve this, you should include the header file generated by javah and configure your compiler the right way.

Thanks,

gopal

Former Member
0 Kudos

Hi gopal,

Everything I do will be answered with an java.lang.UnsatisfiedLinkError.Therefore I believe that SAP fully implements the EJB spec which does not allow JNI calls.

We switched with this approach to .NET and hope to be successfull.

I'm curious about it.

But anyway, thanks for your support.

Regards,Jens