UnsatisfiedLinkError in JAVA. No error while loading DLL but cant use the methods.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Elvan_KR
Posted On:   Wednesday, January 28, 2004 04:53 AM

//Sample Code: import XX.YY.CC.DDDD; public class CLASSNAME{ static { System.loadLibrary("FOOLIB"); } public static DDDDD getFOO() { DDDDD d= null; try { d= new DDDDD (); d.METHODNAME(); } catch (Exception e) { e.printStackTrace(); } return d; } public static void main(String [] args) { DDDDD d = getFOO(); } } Class DDDD has JNI calls. It uses a dll which I copied under system32. It runs as java application with no problem. BUT It doesnt run in web application. It doesnt give any errors at System.loadLibrary("FOOLIB");    More>>

//Sample Code:

			

import XX.YY.CC.DDDD;
public class CLASSNAME{
static {
System.loadLibrary("FOOLIB");
}
public static DDDDD getFOO() {
DDDDD d= null;
try {
d= new DDDDD ();
d.METHODNAME();
} catch (Exception e) {
e.printStackTrace();
}
return d;
}
public static void main(String [] args) {
DDDDD d = getFOO();
}
}


Class DDDD has JNI calls. It uses a dll which I copied under system32.

It runs as java application with no problem.
BUT
It doesnt run in web application.
It doesnt give any errors at
System.loadLibrary("FOOLIB");
When it tries to execute
d.METHODNAME(); it gives UnsatisfiedLinkError.
It look like System.loadLibrary does not work. What should I have done?

I hope someone knows the answer.
Thanks a lot for your help!    <<Less

Re: UnsatisfiedLinkError in JAVA. No error while loading DLL but cant use the methods.

Posted By:   Mark_Lintner  
Posted On:   Tuesday, March 2, 2004 05:25 PM

You would get an exception if loadlibrary failed. What is happening is that the mangled method name in the jni dll is not resolving within the classpath of the class which is calling it. A function "void Java_how_why_when_doSomething();" c++ can be resolved as doSomething_native(); if the package of the calling class is "how.why;" and the java class name that is calling it is "when";. This is because the javah compiler generated the header files in the same package as the calling class incorporating the package path and class name. If you move your files from the package where the jni files were generated the jni code must be redone.
I had encountered this problem myself yesterday and thought Id share what I had learned. By the way the utility depends.exe which comes with VC++ will show you the signiture of the methods in a jni dll if you were not the one to build it and from there you can design your package structure and class names necessary to call them from your code.

Re: UnsatisfiedLinkError in JAVA. No error while loading DLL but cant use the methods.

Posted By:   Thamarai_Selvan  
Posted On:   Friday, January 30, 2004 05:55 AM

put your dll under PATH of your web server.
About | Sitemap | Contact