jnotify linux使用记录
Posted zhou周
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jnotify linux使用记录相关的知识,希望对你有一定的参考价值。
今天使用jnotify,遇到了一些问题记录下
使用jnotify-lib-0.94版 https://sourceforge.net/projects/jnotify/files/
程序启动
java.lang.UnsatisfiedLinkError: no jnotify in java.library.path
2019-04-16 17:56:11,684 [localhost-startStop-1] ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/] - Exception sending context initialized event to listener instance of class [com.groupds.cdr.provider.extract.file.monitor.listener.ContextListener] java.lang.UnsatisfiedLinkError: no jnotify in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at net.contentobjects.jnotify.linux.JNotify_linux.<clinit>(Unknown Source) at net.contentobjects.jnotify.linux.JNotifyAdapterLinux.<init>(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at java.lang.Class.newInstance(Class.java:442) at net.contentobjects.jnotify.JNotify.<clinit>(Unknown Source) at com.groupds.cdr.provider.extract.file.monitor.listener.ContextListener.monitor(ContextListener.java:79) at com.groupds.cdr.provider.extract.file.monitor.listener.ContextListener.contextInitialized(ContextListener.java:44) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4790) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
这是没有指定jnotify library 需在启动脚本加 -Djava.library.path=. (-Djava.library.path=/monitor/jnotify/) jnotify路径
libjnotify.so 这个要根据自己的系统选择对应位数的文件不然会报这个错,默认32位,修改吧64位的替换掉外面的
2019-04-16 18:02:34,577 [localhost-startStop-1] ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/] - Exception sending context initialized event to listener instance of java.lang.UnsatisfiedLinkError: /monitor/jnotify/libjnotify.so: /monitor/jnotify/libjnotify.so: 错误 ELF 类: ELFCLASS32 (Possible cause: architecture word width mismatch) at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at net.contentobjects.jnotify.linux.JNotify_linux.<clinit>(Unknown Source) at net.contentobjects.jnotify.linux.JNotifyAdapterLinux.<init>(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at java.lang.Class.newInstance(Class.java:442) at net.contentobjects.jnotify.JNotify.<clinit>(Unknown Source) at com.groupds.cdr.provider.extract.file.monitor.listener.ContextListener.monitor(ContextListener.java:79) at com.groupds.cdr.provider.extract.file.monitor.listener.ContextListener.contextInitialized(ContextListener.java:44) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4790) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
以上是关于jnotify linux使用记录的主要内容,如果未能解决你的问题,请参考以下文章