JavaHL on two separate JBoss Web Applications LinkageError: Already Loaded by another class loader

StackOverflow https://stackoverflow.com/questions/17082090

  •  31-05-2022
  •  | 
  •  

Question

We have two separate instances of the same web application. One is a sandbox and one a live environment. Both are accessing subversion so we set up svnClientAdapter to use JavaHL. On the startup of the application we are calling JhlClientAdapterFactory.setup();

When the second instance starts I get the error message:

Failed to load JavaHL Library.
These are the errors that were encountered:
Native Library C:\jboss-6.1.0.Final\bin\native\msvcr100.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\msvcp100.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libapr-1.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libapriconv-1.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libeay32.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\ssleay32.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libaprutil-1.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\dbghelp.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libsasl.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libsvn_subr-1.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libsvn_delta-1.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libsvn_diff-1.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libsvn_wc-1.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libsvn_fs-1.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libsvn_repos-1.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libsvn_ra-1.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libsvn_client-1.dll already loaded in another classloader
Native Library C:\jboss-6.1.0.Final\bin\native\libsvnjavahl-1.dll already loaded in another classloader
no svnjavahl-1 in java.library.path
no svnjavahl in java.library.path
java.library.path = C:/jboss-6.1.0.Final/bin/native

It's pretty obvious what the problem is, but I have no idea how to resolve it.

The native libraries are loaded by the svnClientAdapter using the method:

System.loadLibrary(WINDOWSLIBS[i]);
Was it helpful?

Solution 2

I solved it by deploying the needed dll with the application itself. svnClientAdapter is also using a special property subversion.native.library to find the dlls. So in the initialization method I'm getting the absolute path the application is running in with the following method:

String strPath = getClass().getClassLoader().getResource("someResourceThatExists").getPath();
strPath = strPath.replace("filenameOfResource");

Afterwards I'm adding the filename of the library and setting the property:

System.setProperty("subversion.native.library", strPath);

That seems to work quite well.

OTHER TIPS

You could build a third "web application" whose job would be to load native libraries used by whatever other instance is deployed on the server

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top