java.lang.UnsatisfiedLinkError: Native Library XXX.so already loaded in another classloader

前端 未结 4 989
失恋的感觉
失恋的感觉 2020-12-01 18:09

I have deployed one web-application, which contains following code.

System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);

Now, I de

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 18:49

    I got stuck on this exact problem.

    Adding listener in Tomcat (v8.5.58) server.xml file seems to successfully load the dll file (at least the log says so) when Tomcat starts, but when you call the the native method, it fails with java.lang.UnsatisfiedLinkError.

    With or without calling "org.apache.tomcat.jni.Library.loadLibrary("TeighaJavaCore");" in my java code makes no difference, same error remain. I include tomcat-jni dependency in my project to enable the "org.apache.tomcat.jni.Library.loadLibrary("TeighaJavaCore")" call. While, I guess there is no need to call "org.apache.tomcat.jni.Library.loadLibrary("TeighaJavaCore")" in java code (at web application level) as the TeighaJavaCore.dll will be automatically loaded when Tomcat starts (because the listener above is defined for this purpose at Tomcat container level)

    I also check the source code of "org.apache.tomcat.jni.Library.loadLibrary" here, it simply calls "System.loadLibrary(libname)".

    https://github.com/apache/tomcat-native/blob/master/java/org/apache/tomcat/jni/Library.java

提交回复
热议问题