tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From William Claxton <willi...@openasia.net>
Subject problem with classpath modification
Date Thu, 20 Feb 2003 05:51:34 GMT
We encountered an issue when adding a classpath entry to the
'setclasspath.sh' script.  Our environment is RH Linux 8, Apache 2.0, and
Tomcat 4.1.18.  We have connected Apache and Tomcat, and moved our appbase
to another folder (not $TOMCAT_HOME/webapps).

We need to add a classpath entry in order to help our servlet *find
itself*.  This sounds a bit funny, but the servlet reads a config file, and
parses its own tag library.  In a traditional environment we would set an
entry in the classpath for our servlet, and a couple dependent jar files.
In our Tomcat 4.x environment, such configuration is done through XML
files.  As it is, a 'HelloWorld' servlet runs fine in our  'classes'
folder, and dependent jar files can be found in our 'lib' folder.  But our
own servlet cannot *find itself* to bootstrap the tag library.

So we tried to add the entry '/home/web/mediaware/WEB-INF/classes' to the
CLASSPATH by modifying the 'setclasspath.sh' script.  But it caused us to
get various 500 errors - the supporting classes could not be found!  Even
the 'HelloWorld' servlet cannot be found.

To overcome this issue, we make the following modification in the
'setclasspath.sh' file (the 'joinClassPath' function assures that any
existing classpath is inherited, and that there are no null entries in the
classpath):

# Set standard CLASSPATH
# CLASSPATH="$JAVA_HOME"/lib/tools.jar

joinClassPath() {
        # adds string argument to end of existing classpath
        if [ -z "$CLASSPATH" ] ; then
                CLASSPATH=$1
        else
                CLASSPATH=$CLASSPATH:$1
        fi
        export CLASSPATH=`echo $CLASSPATH | tr '::' ':'`
}

joinClassPath "$JAVA_HOME"/lib/tools.jar
joinClassPath "$TOMCAT_HOME"/common/lib/servlet.jar
joinClassPath /home/web/mediaware/WEB-INF/classes
joinClassPath /home/web/mediaware/WEB-INF/lib/activation.jar
joinClassPath /home/web/mediaware/WEB-INF/lib/collections.jar
joinClassPath /home/web/mediaware/WEB-INF/lib/mail.jar

A test servlet, located in our 'classes' folder displays the resulting
classpath as follows:

Output - The classpath is: 
/usr/java/j2sdk1.4.1_01/lib/tools.jar:
/usr/local/jakarta/jakarta-tomcat-4.1.18/common/lib/servlet.jar:
/home/web/mediaware/WEB-INF/classes:
/home/web/mediaware/WEB-INF/lib/activation.jar:
/home/web/mediaware/WEB-INF/lib/collections.jar:
/home/web/mediaware/WEB-INF/lib/mail.jar:
/usr/local/jakarta/jakarta-tomcat-4.1.18/bin/bootstrap.jar 

With this change, our servlet runs fine, and is able to *find itself*
(using the 'classes' entry).  But the question is this: all our servlet
really needs to see is its own directory in the classpath - why does adding
this single entry to our classpath cause Tomcat to fail to find our
supporting jar files, and especially its own servlet jar!  Why is it
necessary for us to forcibly tell Tomcat the classpath for our jar files,
which are sitting in our web application folder (literally under
'/WEB-INF/lib')?

Thanks in advance.


        Regards, Bill Claxton [williamc@openasia.net]
        OpenAsia Solutions provides streaming media & payment solutions.
        Check out http://www.openasia.net
........:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message