tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Unger" <run...@nuance.com>
Subject Classloader issue with Embedded tomcat and WAR deployment
Date Tue, 02 Apr 2002 00:36:10 GMT
I'm making a tomcat 4.0.3 module for netbeans, and I'm running into an odd problem with the
org.apache.catalina.loader.WebappClassLoader.

I'm utilizing the Embedded class to build my server, and I'm using the HostConfig mechanism
for rolling in WAR files.  I have no trouble loading individual servlets, but when I start
the server with a WAR file in place, I get a NoClassDefFoundError: javax/servlet/http/HttpServlet.
 The error is masked by a catch( Throwable t) clause in HostConfig::deployApps, but when I
explicitly print the stack trace, it looks like:

java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:493)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
        at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1631)
        at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:926)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1243)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:865)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:808)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3266)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3395)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:785)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:454)
        at org.apache.catalina.core.StandardHost.install(StandardHost.java:723)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:331)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:398)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:232)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:156)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1131)

        at org.apache.catalina.core.StandardHost.start(StandardHost.java:614)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)

        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:343)
        at org.apache.catalina.startup.Embedded.start(Embedded.java:957)
        at org.netbeans.modules.httpserver.TomcatServer.start(Unknown Source)
        at org.netbeans.modules.httpserver.HttpServerModule$1.run(Unknown Source)


Delving into StandardWrapper line 865, I see the classloader attempting to load the servlet
residing in the WAR file.  This servlet extends HttpServlet, and that's where my error is
coming from.  However, if I stick in a line:

classLoader.loadClass("javax.servlet.http.HttpServlet")

before line 865, everything works fine.  I'm guessing this is because HttpServlet gets loaded
in an earlier run of StandardWrapper::loadServlet() (like when the DefaultServlet gets loaded).

Must I explicitly set the parent classloader for the org.apache.catalina.loader.WebappLoader?
 How?


Rich

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message