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)

 

posted @ 2019-04-16 18:40  zhou周  阅读(1023)  评论(0编辑  收藏  举报