开发者

Native libraries not found in Tomcat

I developed an GWT application which includes some native libraries with JNI. when I test it from eclipse everything works fine, but when I try to deploy it on my Eclipse server it can't find the native libraries.

I followed this tutorial for JNI and Tomcat

but it still can't find them I noticed. That when I read the java.library.path from within my serversided application it is different from what I get when I start Tomcat (displaying the p开发者_如何转开发ath variables with set path).

Any ideas what I am missing?


The simplest answer might be to edit your Tomcat installation's bin/startup script to change the java.library.path to wherever you're copying the native library to. Something like

java -Djava.library.path=/path/to/my/libs existing args

If you're using a shared hosting provider, you'll need to consult with the owner to determine if they'll allow native libraries to be loaded into the container, and if there's a specific location to which the libraries should be copied.

Beyond that, there's the meta problem of your development environment being different from your deployment environment. Ideally, you would have an exact copy (or as close as possible) of the deployment configuration running on your local development machine.


I have struggled with that too. What finally worked for me was to put the JNI libraries in the tomcat/shared/lib directory and set the LD_LIBRARY_PATH environment variable with the path to the JNI library. I also set the JAVA_OPTS environment variable to include the -Djava.library.path option.

Tomcat 7 by the way.

You will need to create the shared/lib directories if they do not exist.

On my Linux server this is how it is set:

LD_LIBRARY_PATH=/usr/tomcat/shared/lib:$LD_LIBRARY_PATH
JAVA_OPTS="-Djava.library.path=/usr/tomcat/shared/lib"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜