You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kip Sigman <ks...@CJ.COM> on 2001/04/26 19:45:45 UTC

Can't find classes in WEB-INF/lib/ after adding web.xml

I am running Tomcat version 3.2.1 on Red Hat Linux 7.

I originally ran a simple application with only JSP pages and a few jars in the WEB-INF/lib/ directory. The JSP pages were able to find the classes in the jar files i had placed in WEB-INF/lib/.

I recently added a web.xml to my application and a servlet that loads upon startup. When i started Tomcat i would get ClassDefNotFound errors regarding classes located in the jar files in WEB-INF/lib but not for classes in WEB-INF/classes. After some frustration i finally added the jars to the classpath in the tomcat.sh script. This fixed the servlet load, but now my JSP pages cannot find classes in a jar file that i did not add to the tomcat.sh classpath, but does exist in the WEB-INF/lib directory.

I'm not sure what happened here, but it appears as if adding the web.xml to my application has caused WEB-INF/lib/*.jar to not be added to the application's classpath. Neither the servlet or the jsp's can find the classes anymore. My temporary workaround has been to just add everything to the tomcat.sh classpath, but that seems kind of hack considering that the server is supposed to find all classes correctly placed in the WEB-INF structure.

Here is a printout of my web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
    <servlet>
        <servlet-name>
            pxsetup
        </servlet-name>
        <servlet-class>
            PxSetupServlet
        </servlet-class>
        <init-param>
            <param-name>dburl</param-name>
            <param-value>jdbc:postgresql:px</param-value>
        </init-param>
        <init-param>
            <param-name>dbuser</param-name>
            <param-value>***</param-value>
        </init-param>
        <init-param>
            <param-name>dbpasswd</param-name>
            <param-value>***</param-value>
        </init-param>
        <init-param>
            <param-name>dbclass</param-name>
            <param-value>org.postgresql.Driver</param-value>
        </init-param>
        <load-on-startup>
           1 
        </load-on-startup>
    </servlet>

    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>
            index.jsp
        </welcome-file>
        <welcome-file>
            index.html
        </welcome-file>
        <welcome-file>
            index.htm
        </welcome-file>
    </welcome-file-list>
</web-app>