Hi:
This is the info given in the JDK 1.2 Documentation
--
In JDK 1.1, once a native library is loaded, it is visible from all class loaders. Therefore two classes in different class loaders may link with the same native method. This leads to two problems:
A class may mistakenly link with native libraries loaded by a class with the same name in a different class loader.
Native methods can easily mix classes from different class loaders. This breaks the name space separation offered by class loaders, and leads to type safety problems.
In JDK 1.2, each class loader manages its own set of native libraries. The same JNI native library cannot be loaded into more than one class loader. Doing so causes UnsatisfiedLinkError to be thrown. For example, System.loadLibrary throws an UnsatisfiedLinkError when used to load a native library into two class loaders. The benefits of the new approach are:
Name space separation based on class loaders is preserved in native libraries. A native library cannot easily mix classes from different class loaders.
In addition, native libraries can be unloaded when their corresponding class loaders are garbage collected.
--
I faced similar problem couple of days back and the solution is to recognize that the class-loader that
loads the servlet cannot be used to load the java class which contains
static{
System.loadLibrary("my32.dll");
}
Hence the approach that I adopted and that worked for me was
1: place the DLL in \\MachineName\\someDir\\WebServer\\lib
2: Let the servlet create an instance of the Java Class JC1 which then creates
the instance of another JavaClass JC2 containing static initializer block
and the logic.
Please note that this is my perception and I look forward to improve my understanding
based on the inputs given by other members of the mailing list.
Thanks
Saifi.
