I am able to compile a java mapscript file from the command line using:
javac -classpath ./mapscript.jar MapServerTest.java
But when i try to turn my code into a servelt and run it over Tomcat i keep getting:
java.lang.UnsatisfiedLinkError: no mapscript in java.library.path
I have tried adding: export CLASSPATH=./mapscript.jar to my ./tomcat5/bin/startup.sh file but that does not seem to help. Am i missing a setting somewhere, why cant Tomcat find the .jar file? I have it in the same directory as my .java file and also in /common/lib and /shared/lib
Thank you for any help that you can provide
On Thu, Aug 03, 2006 at 04:58:43PM -0700, Ryan Ollerenshaw wrote:
I am able to compile a java mapscript file from the command line using: javac -classpath ./mapscript.jar MapServerTest.java But when i try to turn my code into a servelt and run it over Tomcat i keep getting: java.lang.UnsatisfiedLinkError: no mapscript in java.library.path I have tried adding: export CLASSPATH=./mapscript.jar to my ./tomcat5/bin/startup.sh file but that does not seem to help. Am i missing a setting somewhere, why cant Tomcat find the .jar file? I have it in the same directory as my .java file and also in /common/lib and /shared/lib Thank you for any help that you can provide
You might try the Fedora Java list. Especially if you are using the GNU Java that comes with Fedora rather than Sun's.
On Thu, 2006-08-03 at 16:58 -0700, Ryan Ollerenshaw wrote:
I am able to compile a java mapscript file from the command line using:
javac -classpath ./mapscript.jar MapServerTest.java
Hi Ryan,
I'm not exactly sure what you are doing here. Are you trying to compile MapServerTest.java ? And does it require mapscript.jar for it to compile correctly? First, you should define the full path to the mapscript.jar file to avoid confusion, and next, after the compile, you should check that there is a file called MapServerTest.class in the same directory, if it does compile correctly (i.e. without errors).
But when i try to turn my code into a servelt and run it over Tomcat i keep getting:
java.lang.UnsatisfiedLinkError: no mapscript in java.library.path
How are you running it in Tomcat? Have you defined a context, and does it work properly? You should test with a plain web page first to verify that the URL for the context really works.
I have tried adding: export CLASSPATH=./mapscript.jar to my ./tomcat5/bin/startup.sh file but that does not seem to help. Am i missing a setting somewhere, why cant Tomcat find the .jar file? I have it in the same directory as my .java file and also in /common/lib and /shared/lib
IIRC libraries that are placed inside <tomcat-directory>/common/lib are available to all servlets. I'm not clear though on whether this is still the behaviour in Tomcat 5.5. But the thing is, if you *only* need to use the library for your servlet (presumably MapServerTest), you should place the library in the lib directory of your servlet context.
If all that sounds like gibberish, you could start by taking a look at some tutorials. Setting up a context can be confusing.
On 8/4/06, Chong Yu Meng chongym@cymulacrum.net wrote:
On Thu, 2006-08-03 at 16:58 -0700, Ryan Ollerenshaw wrote:
I am able to compile a java mapscript file from the command line using:
javac -classpath ./mapscript.jar MapServerTest.java
Hi Ryan,
I'm not exactly sure what you are doing here. Are you trying to compile MapServerTest.java ? And does it require mapscript.jar for it to compile correctly? First, you should define the full path to the mapscript.jar file to avoid confusion, and next, after the compile, you should check that there is a file called MapServerTest.class in the same directory, if it does compile correctly (i.e. without errors).
System.LoadLibrary(); does not take a absolute path, but i did try using System.load() which can accept a full path to the library and the library does load at compile time (no errors at the System.Load() line), but at runtime i am still getting a UnsatisfiedLinkError when ever i try to use any of the functions from the library.
System.load("/etc/tomcat5/webapps/my_test/WEB-INF/src/libmapscript.so");
But when i try to turn my code into a servelt and run it over Tomcat i keep getting:
java.lang.UnsatisfiedLinkError: no mapscript in java.library.path
How are you running it in Tomcat? Have you defined a context, and does it work properly? You should test with a plain web page first to verify that the URL for the context really works.
yes i do get a class file and use all the basic java functions when i remove all the lines that are giveing my trouble.
I have tried adding: export CLASSPATH=./mapscript.jar to my ./tomcat5/bin/startup.sh file but that does not seem to help. Am i missing a setting somewhere, why cant Tomcat find the .jar file? I have it in the same directory as my .java file and also in /common/lib and /shared/lib
IIRC libraries that are placed inside <tomcat-directory>/common/lib are available to all servlets. I'm not clear though on whether this is still the behaviour in Tomcat 5.5. But the thing is, if you *only* need to use the library for your servlet (presumably MapServerTest), you should place the library in the lib directory of your servlet context.
I have also place the .jar and .so files in the WEB-INF of the servelt that i am creating, still no luck.
Also it is the .so file that i am trying to load, counld this be part of the problem, all the java documentation that i have seen talk about .jar files and not .so
On 8/3/06, Ryan Ollerenshaw ryanollerenshaw@gmail.com wrote:
I am able to compile a java mapscript file from the command line using:
javac -classpath ./mapscript.jar MapServerTest.java
But when i try to turn my code into a servelt and run it over Tomcat i keep getting:
java.lang.UnsatisfiedLinkError: no mapscript in java.library.path
I have tried adding: export CLASSPATH=./mapscript.jar to my ./tomcat5/bin/startup.sh file but that does not seem to help. Am i missing a setting somewhere, why cant Tomcat find the .jar file? I have it in the same directory as my .java file and also in /common/lib and /shared/lib
Thank you for any help that you can provide
Getting closer to the solution. I have found i can use the following code to print out the classpath that my program is actaully using the code is:
Get the System Classloader ClassLoader sysClassLoader = ClassLoader.getSystemClassLoader();
//Get the URLs URL[] urls = ((URLClassLoader)sysClassLoader).getURLs();
for(int i=0; i< urls.length; i++) { out.println(urls[i].getFile()); out.println("<br>"); }
and the classpath that is printed is:
/usr/java/j2sdk1.4.2_12/lib/tools.jar /etc/tomcat5/bin/dist/commons-daemon.jar /etc/tomcat5/bin/bootstrap.jar
But i am not sure where this is getting set, i do have the following in my /tomcat5/bin/startup.sh
export CLASSPATH=./mapscript.jar:.:/etc/tomcat5/webapps/my_test/WEB-INF/classes
so why is this not my classpath at run time??
On Fri, 2006-08-04 at 08:57 -0700, Ryan Ollerenshaw wrote:
so why is this not my classpath at run time??
IIRC, Tomcat resets the classpath when it starts up, so it does not matter what you put in your system classpath or even if you tweak the startup.sh. I could be wrong though, since it has been years (literally) since I touched Tomcat.
But if you want your JAR file to be in the classpath, there are two directories that I seem to recall where you can place the file:
<tomcat-directory>/webapps/<servlet-name>/WEB-INF/classes/ <tomcat-directory>/common/lib/
But it would help if you could answer the following questions:
1. What is the URL that you key into the browser location bar to access the servlet? This is VERY important, because most problems come from the location and the mapping of the servlet. 2. What is the current location for your JAR file? 3. Does the web application get loaded at all? What are the errors in catalina.out when you startup Tomcat? You can check if the web application even exists in Tomcat by accessing the Manager web application (if you installed it).
On 8/4/06, Chong Yu Meng chongym@cymulacrum.net wrote:
On Fri, 2006-08-04 at 08:57 -0700, Ryan Ollerenshaw wrote:
so why is this not my classpath at run time??
IIRC, Tomcat resets the classpath when it starts up, so it does not matter what you put in your system classpath or even if you tweak the startup.sh. I could be wrong though, since it has been years (literally) since I touched Tomcat.
But if you want your JAR file to be in the classpath, there are two directories that I seem to recall where you can place the file:
<tomcat-directory>/webapps/<servlet-name>/WEB-INF/classes/ <tomcat-directory>/common/lib/
But it would help if you could answer the following questions:
- What is the URL that you key into the browser location bar to access
the servlet? This is VERY important, because most problems come from the location and the mapping of the servlet.
http://neuron:8080/my_test/MapServer
- What is the current location for your JAR file?
I have copies of it everywhere now trying to find the correct location so fare i have used: /etc/java/j2sdk1.4.2_12/jre/lib/ext/mapscript.jar /etc/java/j2sdk1.4.2_12/lib/mapscript.jar /etc/tomcat5/common/lib/mapscript.jar /etc/tomcat5/shared/lib/mapscript.jar /etc/tomcat5/webapps/my_test/WEB-INF/classes/mapscript.jar /etc/tomcat5/webapps/my_test/WEB-INF/lib/mapscript.jar /etc/tomcat5/webapps/my_test/WEB-INF/src/mapscript.jar
- Does the web application get loaded at all? What are the errors in
catalina.out when you startup Tomcat? You can check if the web application even exists in Tomcat by accessing the Manager web application (if you installed it).
The only error in my catalina.out file is: java.lang.NoClassDefFoundError I can run a servelt just fine, but when i try to use this mapscript library i keep running into problems. I did create a servelt that prints out the current classpath to the screen and i get:
/usr/java/j2sdk1.4.2_12/lib/tools.jar /etc/tomcat5/bin/dist/commons-daemon.jar /etc/tomcat5/bin/bootstrap.jar
And i dont know and cant find online where this classpath is getting set. As suggested on the web i have added the following to ./startup.sh
export CLASSPATH=./mapscript.jar:.:/etc/tomcat5/webapps/my_test/WEB-INF/classes
and also added the following to /etc/tomcat5/webapps/my_test/.classpath
<classpathentry kind="var" path="TOMCAT_HOME/common/lib/mapscript.jar"/>