File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Websphere and the fly likes Native lib is already loaded in another classloader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Native lib is already loaded in another classloader" Watch "Native lib is already loaded in another classloader" New topic

Native lib is already loaded in another classloader

Chris Wang
Ranch Hand

Joined: Jan 13, 2004
Posts: 34
I have a web application deployed in WAS Server 6.1 which sitting on AIX. The web application is using a native (c++) library. I setup the native library as a shared libary. Every time when I reinstalled the application or restarted the application, I got the following exception:
java.lang.UnsatisfiedLinkError: arjni70 (Library is already loaded in another ClassLoader)
at java.lang.ClassLoader.loadLibraryWithPath(
at java.lang.ClassLoader.loadLibraryWithClassLoader(
at java.lang.System.loadLibrary(
at com.remedy.arsys.api.Proxy.<clinit>(
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(
at com.remedy.arsys.api.DefaultProxyManager.getProxy(
at com.remedy.arsys.api.Util.ARSetServerPort(

To avoid the exception I have to restart the WAS server. Could anyone please explain why?

Thanks in advance!

dixan martinez

Joined: Sep 22, 2003
Posts: 2
By "reinstall" you mean "update" using WAS console or wsadmin script, right?

Java specifications state a native library can't be loaded by two different classloaders in the same process.

In this case the class which makes JNI is being reloaded by a different classloader everytime you update or restart it, so the problem occurs.

One solution is to create a shared library with the JNI class, and the create a classloader for your app server and associate that shared library to it. This way, restarting your app won't make any change to the class loader in charge of your JNI class
I agree. Here's the link:
subject: Native lib is already loaded in another classloader
It's not a secret anymore!