UI设计界面 UI设计界面 主题:1059 回复:2190


夜无邪 发布于 2017-08-14 字数 1357 浏览 1523 回复 3

项目部署在LINUX环境下的tomcat中 启动后提示
Exception in thread "Thread-2" java.lang.UnsatisfiedLinkError: Unable to load library 'libJavaSense4Pkg': cannot open shared object file: No such file or directory
at com.sun.jna.NativeLibrary.loadLibrary(
at com.sun.jna.NativeLibrary.getInstance(
at com.sun.jna.Library$Handler.<init>(
at com.sun.jna.Native.loadLibrary(
at com.sun.jna.Native.loadLibrary(
at sunyan.lock.LinuxCheckAdapter.loadLib(
at sunyan.lock.LinuxCheckAdapter.getLinuxCheckAdapter(
at sunyan.lock.SystemCheckAdapter.getSystemCheckAdapter(

so文件已经放在了所有可能的目录 包括jre下 usr/lib下等等 仍然提示如上错误,请教各位linux so文件需要特殊处理吗 还是其他地方没写对 我加载lib是用的



需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

支持 Markdown 语法,需要帮助?


偏爱自由 2017-09-16 3 楼

1.System.loadLibrary 参数为库文件名,不包含库文件的扩展名

2.可以试试 System.load 参数为库文件的绝对路径。

瑾兮 2017-09-13 2 楼


晚风撩人 2017-08-19 1 楼


The important thing to know about using JNI under Tomcat is that one cannot place the native libraries OR their JNI interfaces under the WEB-INF/lib or WEB-INF/classes directories of a web application and expect to be able to reload the webapp without restarting the server. The class that calls System.loadLibrary(String) must be loaded by a classloader that is not affected by reloading the web application itself.

Thus, if you have JNI code that follows the convention of including a static initilaizer like this:

class FooWrapper {
static {

native void doFoo();


then both this class and the shared library should be placed in the $CATALINA_HOME/shared/lib directory.

Note that under Windows, you'll also need to make sure that the library is in the java.library.path. Either add %CATALINA_HOME%sharedlib to your Windows PATH environment variable, or place the DLL files in another location that is currently on the java.library.path. There may be a similar requirement for UNIX based system (I haven't checked), in which case you'd also have to add $CATALINA_HOME/shared/lib to the PATH environment variable. (Note: I'm not the original author of this entry.)

The symptom of this problem that I encountered looked something like this -

java.lang.UnsatisfiedLinkError: Native Library WEB-INF/lib/ already loaded in another classloader
at java.lang.ClassLoader.loadLibrary0(
If the UnsatisfiedLinkError is intermittent, it may be related to Tomcat's default session manager. It restored previous sessions at startup. One of those objects may load the JNI library. Try stopping the Tomcat JVM, deleting the SESSIONS.ser file, then starting Tomcat. You may consider changing the session persistence manager at this time.

Note that Tomcat 6.0.14 the $CATALINA_HOME/shared/lib directory does not exist. You will need to add this and you will need to edit $CATALINA_HOME/conf/ so that the shared.loader line looks like this shared.loader=$CATALINA_HOME/shared/lib