tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject RE: java.lang.NoClassDefFoundError: javax/servlet/Filter
Date Fri, 24 Jan 2003 17:54:03 GMT

On Fri, 24 Jan 2003, Lorenti, John wrote:

> Date: Fri, 24 Jan 2003 08:52:36 -0500
> From: "Lorenti, John" <>
> Reply-To: Tomcat Users List <>
> To: 'Tomcat Users List' <>
> Subject: RE: java.lang.NoClassDefFoundError: javax/servlet/Filter
> Tim,
> Maybe what I've done is taboo :-(  I've placed the top level directory that
> has all of our custom Java classes (shared by all applications on the
> machine) on the Tomcat classpath.  Tomcat is finding my TestFilter class
> there (since I chose to leave the class there instead of placing it under
> the context's WEB-INF/classes directory) which in turn references
> javax.servlet.Filter.  Since other applications besides those within Tomcat
> are using the "common" code, I'd like to keep it in one place outside of
> Tomcat's structure.  However, from what you've mentioned, it seems that I
> may need to keep any Tomcat/Servlet specific classes where Tomcat is
> expecting them to reside and not depend upon the classpath.
> If this is the case, do you think that a Tomcat-friendly solution would be
> to separate my classes into two disjoint sets - one having anything related
> to servlets, and the other containing my "common" (non-Servlet specific)
> classes?  The first set would live under the context's WEB-INF hierarchy,
> and the other set living on the classpath.  If this can work, then maybe I
> can "have my cake and eat it too."
> Is there a better/more preferred way to accomplish class sharing beyond
> Tomcat's purview?

The standard Tomcat scripts ignore the classpath variable for a reason --
it is *way* to easy to get yourself into trouble, and this is just one of
those ways.

Classes on the class path (assuming you hacked the startup script to
include some) are loaded from the system class loader, and therefore
cannot see anything in common/lib (including servlet.jar).  Therefore, you
can't put a Filter, or anything else that implements from javax.servlet,
in the class path.

And, no, moving servlet.jar onto the class path someplace will just cause
you other sorts of grief.  My strong advice is to do what Tomcat wants you
to do, and put your classes where it's looking for them.
> Thank you.
> -John

Craig McClanahan

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message