• Post Reply Bookmark Topic Watch Topic
  • New Topic

Native lib is already loaded in another classloader  RSS feed

Chris Wang
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(ClassLoader.java:953)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:922)
at java.lang.System.loadLibrary(System.java:451)
at com.remedy.arsys.api.Proxy.<clinit>(Proxy.java:51)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
at com.remedy.arsys.api.DefaultProxyManager.getProxy(DefaultProxyManager.java:60)
at com.remedy.arsys.api.Util.ARSetServerPort(Util.java:1461)
at com.ibm.msp.sym_smartcall.Focus.FocusAPI.focusTx(FocusAPI.java:118)
at com.ibm.msp.sym_smartcall.command.FocusTask.run(CMDReceiver_Submit.java:495)

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

Thanks in advance!

dixan martinez
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!