tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Unger" <run...@nuance.com>
Subject RE: Classloader issue with Embedded tomcat and WAR deployment
Date Wed, 03 Apr 2002 02:21:26 GMT
I figured it out.  For the curious, I was specifying a loader for my root context, but that
wasn't being propogated to any WAR files, only to servlets explicitly added to the root context
at startup time.  I had to set the parent classloader on the host which was loading the WAR
files.

Rich

> -----Original Message-----
> From: Richard Unger 
> Sent: Monday, April 01, 2002 4:36 PM
> To: 'tomcat-dev@jakarta.apache.org'
> Subject: Classloader issue with Embedded tomcat and WAR deployment
> 
> 
> 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(WebappC
> lassLoader.java:926)
>         at 
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappC
> lassLoader.java:1360)
>         at 
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappC
> lassLoader.java:1243)
>         at 
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardW
> rapper.java:865)
>         at 
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.
> java:808)
>         at 
> org.apache.catalina.core.StandardContext.loadOnStartup(Standar
> dContext.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(HostConf
> ig.java:232)
>         at 
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(L
> ifecycleSupport.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