Hi all,
Technical summary: I'm developing a Java web service deployed on GlassFish v3, running on CentOS 5.
My web service uses functionality provided by a native library (.so) . The native library works fine, however I am not having much luck in configuring the environment correctly to load the native library yet not be affected by web app re-deployment, without restart the app server.
What I've done so far is:
Initially I loaded the library (static {System.load(path/to/libabc.so)};) in the web service code, all paths set correctly, and it works fine, until I re-deploy the application and it complains that the library is loaded by another ClassLoader. I found out that native libs are only loaded once.
To try and solve this I then removed the library-loading code from the web application, created a Singleton class, wrapped it into a Lifecyle module, deployed it to GlassFish shared lib folder and then configured GlassFish to run the wrapper when it starts up. The idea being that now all web applications would be able to reference it since it is not tied to one particular web app and loaded by a ClassLoader higher in the hierarchy.
When GlassFish starts up the native library is loaded successfully ( linux> lsof | grep libabc.so ). However, the web service code fails with a UnsatisfiedLinkError when executing the native method in my web service Java code. It seems to me that code in the web application does not have access to the library loaded at start-up.
Can anyone tell me what I'm doing wrong?
Thanks in advance.