You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dan Barron <db...@dswllc.com> on 2004/11/10 03:17:54 UTC
JNI Error with Tomcat
Hello,
I am having trouble loading a native library for use within Tomcat web
applications. I read the wiki entry and found the latest JNI posts - but I
still don't quite get it and still have an error. I'm hoping someone out
there has been through this and has some suggestions.
My environment is Tomcat 5.0.28, Fedora Core 2, JDK 1.5.0, Apache 2.0.52
connecting to Tomcat with jk2.
I created a wrapper class to load the library libmpascript.so and placed
the class file into the <tomcat-root>/shared/classes directory so it would
load with the built in tomcat shared classloader and be available for all
web applications. This sound correct?
public class MapScriptWrapper {
static { System.loadLibrary("mapscript"); }
native void load();
}
The library lives in /usr/local/lib/special and when starting up tomcat I
set JAVA_OPTS=-Djava.library.path=/usr/local/lib/special in the
/etc/init.d/tomcat script. Does this need to be in
<tomcat-root>/bin/catalina.sh? I could also make it a global variable in
/etc/profile but have not tried that yet.
excerpt from /etc/init.d/tomcat
...
start() {
echo -n "Starting tomcat: "
JAVA_OPTS='-Djava.library.path=/usr/local/lib/special'
export JAVA_OPTS
set | grep JAVA
chown -R $TOMCAT_USER:$TOMCAT_USER /usr/local/tomcat/*
su -l $TOMCAT_USER -c '/usr/local/tomcat/bin/startup.sh'
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
return $RETVAL
}
...
There is a correpsonding mapscript.jar file which maps obejcts to the
library that is available via the CLASSPATH and when I create a jsp file
and try to create an object that points to the library I get the dreaded
UnsatisfiedLinkError - which tells me the library is not loaded and available.
java.lang.UnsatisfiedLinkError: new_mapObj
edu.umn.gis.mapscript.mapscriptJNI.new_mapObj(NativeMethod)
edu.umn.gis.mapscript.mapObj.<init>(mapObj.java:334)
org.apache.jsp.mapscript_002dtest_jsp._jspService(mapscript_002dtest_jsp.java:52)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Any ideas would be appreciated! Thanks!
Dan Barron
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org