I think its a limitation of java, it appears you can't load a native library
from more than one class loader at a time.

To work around it, I have a class that wraps the native library, and load
the native library inside a static block as you say.  I then make this class
available to a higher level class loader.  Since the web-app class loaders
are children of the the orion top level class loader, and there is only one
top level class loader, the library is only loaded once, but available to
all web-apps.  You can make the wrapper class available at the default
application level, by adding <library> tags to application.xml, or at the
system classpath level by starting orion using "java -cp
orion.jar;myJNIwrapperClass.jar com.evermind.server.ApplicationServer".

Hope this helps,
Andre

-----Original Message-----
From: Etienne Bernard [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 29, 2001 4:24 PM
To: Orion-Interest
Subject: Orion and JNI


Hi,

I am trying to use a native class in a servlet. The library containing
the implementation of the native methods is loaded at the servlet
initialization (static { ... } block), and everything works fine.

However, when my application gets redeployed, the next time I try to
access my servlet I get an exception:

java.lang.UnsatisfiedLinkError: Native Library libsipssubscription.so
already loaded in another classloader
  at java.lang.Error.<init>(Error.java:52)
  at java.lang.LinkageError.<init>(LinkageError.java:45)
  at java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:44)
  at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1434)
  at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1315)
  at java.lang.Runtime.load0(Runtime.java:715)
  at java.lang.System.load(System.java:826)
  at com.ecompil.sipswrapper.SIPSApiSub.<clinit>(SIPSApiSub.java:68)
  at
com.ecompil.web.SIPSSubscriptionRequest.processSubscription(SIPSSubscription
Request.java:60)

Is there a way to avoid such an error ?

Thanks in advance.
-- 
Etienne Bernard <[EMAIL PROTECTED]>
Senior Software Engineer - FullSIX - http://www.fullsix.com/

Reply via email to