You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ju...@bbs.darktech.org on 2002/09/10 15:55:02 UTC
Using JNI under Tomcat
Hi,
I have a JNI library I wrote and an associated Java class with 'native' functions using that DLL. In the class file I have:
static
{
System.loadLibrary("mylib");
}
but due to the fact Tomcat uses multiple classloaders I sometimes get UnsatisfiedLinkExceptions when loading a JSP file which means use of this bean which leads the DLL into memory. Sun has made it explicitly clear they will not be fixing this issue anytime soon so people must resort to a workaround. The workaround is that a top-level classloader must load all DLLs being used by children classloaders; this gurantees the DLL is only loaded once and by only that single (parent) classloader. Under Tomcat, I don't think the developers give the users enough control or the ability to make use of this workaround so, in essense, it is impossible to relyably use JNI under Tomcat. The second I modify any of my classes which (due to a long list of dependencies) make use of the native library a new classloader seems to be spawned and the library is loaded a second time which causes the aforementioned error. Ignoring the exception is not an option as you lose access to the native functions.
I await your feedback,
Gili Tzabari
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>