Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
235 views
in Technique[技术] by (71.8m points)

eclipse - Indri library java.lang.UnsatisfiedLinkError..change to java.lang.NoClassDefFoundError only on the server

I have this web application where I use the indri.jar in it. I am using eclipse.

I have put it in the lib folder and did "add to build path" option.

Also in "Build Path -> Configure -> Order and Export", everything is checked.

Also in "Properties -> Deployment assembly", all the jar files are added. Then I export the project to .war and put it on the server.

I checked the lib folder of the deployed project and the jar file is there.

Also my machine and server are both 64 bit, since for this library there are two versions for 32 and 64 bit, and it wont work if you use them instead of each other.

It is also important to say that we are a team working on this project using git repository, and when the other side pull the code all the libraries and everything is attached and they have no problem running the code. (They have installed indri, and I did install it on the server)

Still when I open the page in the browser it gives me "error in ajax call" and when I trace the error it gives me:

description The server encountered an internal error () that prevented it from fulfilling    this request.


exception

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.UnsatisfiedLinkError: no indri_jni in java.library.pathorg.etc.


root cause

org.glassfish.jersey.server.ContainerException: java.lang.UnsatisfiedLinkError: no indri_jni in java.library.pathorg.glassfish.etc


root cause

java.lang.UnsatisfiedLinkError: no indri_jni in java.library.pathjava.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)java.lang.Runtime.loadLibrary0.etc.

I searched a lot and then I ran this line on the server:

java -Djava.library.path=/path/to/jnilib/directory MainClass

Then the error changed to this:

exception

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: Could not initialize class lemurproject.indri.indriJNIorg.glassfish

root cause

org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: Could not initialize class lemurproject.indri.indriJNIorg.glassfish.jersey.servlet

java.lang.NoClassDefFoundError: Could not initialize class lemurproject.indri.indriJNIlemurproject.indri.QueryEnvironment.<init>(QueryEnvironment.java:39)LogicLayer.IndriIndex.processQuery(I...

Note:

  1. Indri is working on command line on the server, so the problem is not with indri but is with deploying.

  2. When I deploy the code by commenting the lines related to Indri, it works, that shows I am exporting to .war correctly.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is an important file in indri installation which is libinrdi_jni.so, which has the role of linking java to c language which is the language the library has been written to. It is located in the indri installation foler: ./install/lib/libindri_jni.so.

My code couldn't find this file. So I had to put it somewhere in the server that it will definitely look into and then it did find it and everything worked.

To make sure that you will have this file you need to install indri in this way:

./configure --enable-java --with-javahome=address/to//jdk1.7.0 --prefix=/address/to/indri-5.7/install

make all install

make sure to download the jdk1.7 and extract it yourself instead of using any install package. This way the libindri_jni.so will be installed.

Then to make sure that your java program will work, you need to run IndexUI.jar, and RetUI.jar, provided in the indri folder. If it works, then your program will work too, but if it is not working, then try running this command:

export LD_LIBRARY_PATH=/address/to/indri-5.7/install/lib

then run the jar file again, if the problem has been resolved, the libindri_jni.so file is the problem and you can solve it by locate it in a place that program can definitely find it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...