Thank you so much for your time! I encountered a problem using jsmile's libjsmile.jnilib in an online Java service on the Apache Tomcat server. Could I ask for your help?
It seems that the error happens because I have two online web applications that both load libjsmile.jnilib library, and when one of them has already loaded this library, the other app will encounter this error:
<html><head><title>Apache Tomcat/7.0.64 - Error report</title><style><!--H1 {font-family:…}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - Servlet execution threw an exception</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>Servlet execution threw an exception</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>javax.servlet.ServletException: Servlet execution threw an exception
</pre></p><p><b>root cause</b> <pre>java.lang.UnsatisfiedLinkError: Native Library /System/Library/Java/Extensions/libjsmile.jnilib already loaded in another classloader
java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1798)
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1748)
java.lang.Runtime.loadLibrary0(Runtime.java:823)
java.lang.System.loadLibrary(System.java:1044)
smile.Wrapper.<clinit>(Wrapper.java:38)
KCModeler.computeBNUserModels(KCModeler.java:127)
Aggregate.computeUserLevels(Aggregate.java:446)
Aggregate.<init>(Aggregate.java:255)
GetContentLevels.doGet(GetContentLevels.java:134)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.64 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.64</h3></body></html>
I tried to detect whether this library is loaded or not and then avoid another app loading this library, but I couldn't solve it. For example, I changed the code to this:
Code: Select all
NativeLibraries nativelib = new NativeLibraries();
List<String> loadedLibs = nativelib.getLoadedLibraries();
System.out.println("\tLoadedLibs: " + loadedLibs);
boolean loaded = false;
for (String loadedLib : loadedLibs){
if (loadedLib.contains("jsmile"))
loaded = true;
}
if (!loaded){
System.loadLibrary("jsmile");
System.out.println("\tWARNING: finish loading jsmile library");
nativeStaticInit();
System.out.println("\tWARNING: finish calling nativeStaticInit!");
}
else{
System.out.println("\tWARNING: not loading jsmile library; not calling nativeStaticInit!");
}
<html><head><title>Apache Tomcat/7.0.64 - Error report</title><style><!--H1 {font-family:…;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - Servlet execution threw an exception</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>Servlet execution threw an exception</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>javax.servlet.ServletException: Servlet execution threw an exception
</pre></p><p><b>root cause</b> <pre>java.lang.UnsatisfiedLinkError: smile.Network.createNative(Ljava/lang/Object;)J
smile.Network.createNative(Native Method)
smile.Wrapper.<init>(Wrapper.java:10)
smile.Network.<init>(Network.java:5)
KCModeler.computeBNUserModels(KCModeler.java:127)
Aggregate.computeUserLevels(Aggregate.java:446)
Aggregate.<init>(Aggregate.java:255)
GetContentLevels.doGet(GetContentLevels.java:134)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.64 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.64</h3></body></html>
</pre></p><p><b>root cause</b> <pre>java.lang.UnsatisfiedLinkError: smile.Wrapper.nativeStaticInit()V
smile.Wrapper.nativeStaticInit(Native Method)
smile.Wrapper.<clinit>(Wrapper.java:54)
KCModeler.computeBNUserModels(KCModeler.java:127)
Aggregate.computeUserLevels(Aggregate.java:456)
Aggregate.<init>(Aggregate.java:265)
GetContentLevels.doGet(GetContentLevels.java:134)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.64 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.64</h3></body></html>
Please let me know whether I should provide more information (It will take me some time to replicate the error but I hope I have attached the main information). Thank you so much for your help!!
Yun
Intelligent Systems Program
University of Pittsburgh