Tomcat problem with classpath
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ryan_Laudrup
Posted On:   Wednesday, April 11, 2001 02:00 AM

I have installed Tomcat 3.2.1 and created a directory under the webapps directory for my application. My application needs some 3rd party jar files so I've put them in the webapps/myapp/WEB-INF/lib directory. However, it seems Tomcat does not automatically include those files in the classpath. My workaround is to modify tomcat.sh to add the files to the classpath and it worked. But my understanding is that Tomcat should automatically do this for me (according to the Servlet Spec). Does anyone know what is wrong with my setup?

Re: Tomcat problem with classpath

Posted By:   AlessandroA_Garbagnati  
Posted On:   Wednesday, April 11, 2001 10:21 AM

Ryan,

Yes, according to the Servlet Specification, Tomcat automatically adds for each context, /WEB-INF/classes and all the *.jar (not *.zip, just *.jar) located in /WEB-INF/lib. It's working for me.

At the same time, I never had to change tomcat.sh to have tomcat reading the classpath. These lines (from the default tomcat.sh, in fact, are the one responsible for the generation of the classpath:

for i in ${TOMCAT_HOME}/lib/* ; do
if [ "$CLASSPATH" != "" ]; then
CLASSPATH=${CLASSPATH}:$i
else
CLASSPATH=$i
fi
done

if [ -f ${JAVA_HOME}/lib/tools.jar ] ; then
# We are probably in a JDK1.2 environment
CLASSPATH=${CLASSPATH}:${JAVA_HOME}/lib/tools.jar
fi

I don't have any idea why your jars aren't added to the classpath. It could be that if the context classpath is added at the end of the original one, and you have some old version of the same package in the main lib directory, the ClassLoader does not get to the second... but it looks very weird...
About | Sitemap | Contact