Hi
we're using JPathWatch in an OSGI based web application deployed on Tomcat (>7). Currently we have two .war files deployed on one TC instance each of them using JPathWatch functionality since classes of both war files have to watch different folders. During deployment of the war files we get an UnsatisfiedLinkError:. It seems that Tomcat tries to load the same library several times.
java.lang.UnsatisfiedLinkError: Native Library C:\…t\Server\apache-tomcat-7.
0.14\temp\jpathwatch-nativelib-v-0-94-jpathwatch-native.dll already loaded in an
other classloader
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1768)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1699)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at name.pachler.nio.file.impl.NativeLibLoader.extractAndLoadLibrary(Nati
veLibLoader.java:397)
at name.pachler.nio.file.impl.NativeLibLoader.loadLibrary(NativeLibLoade
r.java:247)
at name.pachler.nio.file.impl.WindowsPathWatchService.<clinit>(WindowsPa
thWatchService.java:120)
at name.pachler.nio.file.ext.Bootstrapper.newWatchService(Bootstrapper.j
ava:83)
at name.pachler.nio.file.FileSystems$1.newWatchService(FileSystems.java:
40)
at de.info.hsag.edicat.preconverter.WatchDirClient.run(WatchDirClient.ja
va:68)
at java.lang.Thread.run(Thread.java:662)
How can we avoid this Exception? We alreay read the FAQs and tried several build/deploy options but nothing works so far (for example TC doesn't find the jar if we store it in the TC's /lib folder)
Do you have any idea how to solve the problem?
Thanks in advance, Roland .
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The question is actually a classic :) (and I think it is mentioned in the FAQ somewhere…)
The first thing to just get things to work would be to move jpathwatch-*.jar into the system classpath for tomcat (try java's -cp option when launching Tomcat). This will cause the system class loader to load jpathwatch classes once, instead of each of your web apps loading them with their own class loaders twice (that's what that exception is: jpathwatch is loaded twice, and therefore the native library is attempted to be loaded twice as well, which won't work).
Let me know how you're going,
Cheers,
Uwe
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Uwe,
thanks for your answer. The problem is the OSGi plugin classpath which cannot find the classes in the TC's /lib folder. The solution is to expose the jpathwatch jar to the OSGi environment. Therefore you have to extend the catalina.bat/sh with 2 entries:
First you have to add the jpathwatch lib to the TC's /lib folder and add it to the tomcat classpath by adding the following line:
set CLASSPATH = %CLASSPATH% %CLASSPATH%%CATALINA_HOME%\lin\jpathwatch-0-94.jar"
Second you have to export the package to the OSGi environment by adding the following line:
set JAVA_OPTS=%JAVA_OPTS% -Dorg.osgi.framework.system.packages.extra=name.pachler.nio.file
Hope this helps others.
Best regards,
Roland
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
we're using JPathWatch in an OSGI based web application deployed on Tomcat (>7). Currently we have two .war files deployed on one TC instance each of them using JPathWatch functionality since classes of both war files have to watch different folders. During deployment of the war files we get an UnsatisfiedLinkError:. It seems that Tomcat tries to load the same library several times.
java.lang.UnsatisfiedLinkError: Native Library C:\…t\Server\apache-tomcat-7.
0.14\temp\jpathwatch-nativelib-v-0-94-jpathwatch-native.dll already loaded in an
other classloader
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1768)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1699)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at name.pachler.nio.file.impl.NativeLibLoader.extractAndLoadLibrary(Nati
veLibLoader.java:397)
at name.pachler.nio.file.impl.NativeLibLoader.loadLibrary(NativeLibLoade
r.java:247)
at name.pachler.nio.file.impl.WindowsPathWatchService.<clinit>(WindowsPa
thWatchService.java:120)
at name.pachler.nio.file.ext.Bootstrapper.newWatchService(Bootstrapper.j
ava:83)
at name.pachler.nio.file.FileSystems$1.newWatchService(FileSystems.java:
40)
at de.info.hsag.edicat.preconverter.WatchDirClient.run(WatchDirClient.ja
va:68)
at java.lang.Thread.run(Thread.java:662)
How can we avoid this Exception? We alreay read the FAQs and tried several build/deploy options but nothing works so far (for example TC doesn't find the jar if we store it in the TC's /lib folder)
Do you have any idea how to solve the problem?
Thanks in advance, Roland .
Hi Roland,
The question is actually a classic :) (and I think it is mentioned in the FAQ somewhere…)
The first thing to just get things to work would be to move jpathwatch-*.jar into the system classpath for tomcat (try java's -cp option when launching Tomcat). This will cause the system class loader to load jpathwatch classes once, instead of each of your web apps loading them with their own class loaders twice (that's what that exception is: jpathwatch is loaded twice, and therefore the native library is attempted to be loaded twice as well, which won't work).
Let me know how you're going,
Cheers,
Uwe
Hi Uwe,
thanks for your answer. The problem is the OSGi plugin classpath which cannot find the classes in the TC's /lib folder. The solution is to expose the jpathwatch jar to the OSGi environment. Therefore you have to extend the catalina.bat/sh with 2 entries:
First you have to add the jpathwatch lib to the TC's /lib folder and add it to the tomcat classpath by adding the following line:
set CLASSPATH = %CLASSPATH% %CLASSPATH%%CATALINA_HOME%\lin\jpathwatch-0-94.jar"
Second you have to export the package to the OSGi environment by adding the following line:
set JAVA_OPTS=%JAVA_OPTS% -Dorg.osgi.framework.system.packages.extra=name.pachler.nio.file
Hope this helps others.
Best regards,
Roland