Tomcat中的本机库UnsatisfiedLinkError + Windows + eclipse [英] Native library in Tomcat UnsatisfiedLinkError + Windows + eclipse

查看:489
本文介绍了Tomcat中的本机库UnsatisfiedLinkError + Windows + eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题可能早先在SO上被问到,请放心,我已经检查了所有可用的解决方案。仍然无法让它运行

This question might have been asked earlier on SO, and please be assured I did check all the available solutions. Was still unable to get it to run

我的问题与本文中所述完全相同 Tomcat中的共享本机库UnsatisfiedLinkError

My problem is exactly as described in this post Shared native library in Tomcat UnsatisfiedLinkError

独立Java应用程序运行良好。然而,Tomcat(9)无法运行并抛出

Standalone Java application is running perfectly well. However with Tomcat(9) it fails to run and throws

java.lang.UnsatisfiedLinkError: third_party.org.chokkan.crfsuite.crfsuiteJNI.swig_module_init()V
    at third_party.org.chokkan.crfsuite.crfsuiteJNI.swig_module_init(Native Method)
    at third_party.org.chokkan.crfsuite.crfsuiteJNI.<clinit>(crfsuiteJNI.java:87)
    at third_party.org.chokkan.crfsuite.Tagger.<init>(Tagger.java:39)

我知道我的DLL正在加载,我也检查了我的dll文件夹,是在PATH变量。我还检查了正在加载的类,并且DLL正在加载。

I know that my DLL is being loaded, also I checked that the folder my dll is in, is in the PATH variable. I have also checked the classes being loaded and the DLL is infact being loaded.

我注意到3种类型的UnsatisfiedLinkError在SO

I have noticed 3 types of UnsatisfiedLinkError at SO

1)java.lang.UnsatisfiedLinkError:third_party.org .chokkan.crfsuite.crfsuiteJNI.swig_module_init() V
2)java.lang.UnsatisfiedLinkError:third_party.org.chokkan.crfsuite.crfsuiteJNI.swig_module_init() B
3)类加载器加载两次。

1) java.lang.UnsatisfiedLinkError: third_party.org.chokkan.crfsuite.crfsuiteJNI.swig_module_init()V 2) java.lang.UnsatisfiedLinkError: third_party.org.chokkan.crfsuite.crfsuiteJNI.swig_module_init()B 3) Where the class loader is loading twice.

我相信 V ,最后是表示某事。但是我无法弄清楚究竟是什么?

I believe the V , at the end does signifies something. But I am not able to figure out exactly what?

上面分享的SO文章中的一个可接受的答案声称它与版本有关。我不明白这是一个可以接受的解决方案,因为它作为一个独立的java应用程序运行时工作得很好。

One of the accepted answers in the SO post I shared above claims it has something to do with version. I do not understand how is that an acceptable solution since it works perfectly well when run as a standalone java application.

已经花了很多时间,任何帮助都是可观的。

Wasted a lot of time already, any help is appreciable.

感谢
Chahat

Thanks Chahat

推荐答案

同样的问题。我终于找到了解决方案。它适用于我。

I faced with the same issue. I finally find the solution. It works for me.

首先,我安装了libLBFGS和crfsuite。你可以在这里找到指示( http://www.chokkan.org/software/crfsuite /manual.html )。 libcrfsuite.so将安装在/ usr / local / lib

First, I instaled libLBFGS and crfsuite. You can find the instruction here (http://www.chokkan.org/software/crfsuite/manual.html). The libcrfsuite.so will be install in /usr/local/lib

其次,我编辑tomcat配置以加载本机库。我在tomcat bin文件夹中创建setenv.sh,设置CATALINA_OPTS变量的内容:

Second, I edit tomcat config in order to load native library. I create setenv.sh in tomcat bin folder, set CATALINA_OPTS variable with content :

export CATALINA_OPTS = - Djava.library.path = / usr / local / bin:/ usr / local / lib

export CATALINA_OPTS="-Djava.library.path=/usr/local/bin:/usr/local/lib"

最后,我使用了自定义ServletContextListener,并通过System.load()显式加载libcrfsuite.so。我去这个链接下载lib( https:// github.com/vinhkhuc/jcrfsuite/tree/master/src/main/resources/crfsuite-0.12

Finally, I used custom ServletContextListener and explicitly load libcrfsuite.so by System.load(). I go this link to download lib (https://github.com/vinhkhuc/jcrfsuite/tree/master/src/main/resources/crfsuite-0.12)

这篇关于Tomcat中的本机库UnsatisfiedLinkError + Windows + eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆