Craig wrote:
>>Servlets that load at startup are loaded from the webapp class loader
>>(along with all other servlets, filters, and application event >>listeners),
>>which checks things in the following order:
>>
>> /WEB-INF/classes of your web-app
>> /WEB-INF/lib/*.jar of your web-app
>> $CATALINA_HOME/lib
>> $CATALINA_HOME/common/lib
>> System class loader (configured in catalina.sh or catalina.bat
>> from a predefined CLASSPATH)
>> $JAVA_HOME/jre/lib/ext (i.e. the system extensions directory)
>> Java runtime classes
This should be an easy one to reproduce or explain away. I can't get Tomcat
4.0b7 to see classes in the webapps directory at startup.
Try adding the following to your web.xml file. The class is already in the
examples context. At startup, Tomcat shows a class not found error in the log
file. Is there something else that is needed that I am missing here?
<!-- SnoopServlet -->
<servlet>
<servlet-name>SnoopServlet</servlet-name>
<servlet-class>SnoopServlet</servlet-class>
<load-on-startup>7</load-on-startup>
</servlet>
2001-08-14 20:56:35 StandardWrapper[/manager:SnoopServlet]: Marking servlet
SnoopServlet as unavailable
2001-08-14 20:56:35 StandardContext[/manager]: Servlet /manager threw load()
exception
javax.servlet.ServletException: Wrapper cannot find servlet class SnoopServlet
or a class it depends on
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:796)
at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3240
)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3350)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:785)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:415)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:643)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:599)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:777)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:463)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.ja
va:155)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1131)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:278)
at org.apache.catalina.core.StandardService.start(StandardService.java:368)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:473)
at org.apache.catalina.startup.Catalina.start(Catalina.java:738)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:657)
at org.apache.catalina.startup.Catalina.process(Catalina.java:178)
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:202)
----- Root Cause -----
java.lang.ClassNotFoundException: SnoopServlet
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:12
64)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:11
13)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:790)
at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3240
)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3350)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:785)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:415)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:643)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:599)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:777)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:463)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.ja
va:155)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1131)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:278)
at org.apache.catalina.core.StandardService.start(StandardService.java:368)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:473)
at org.apache.catalina.startup.Catalina.start(Catalina.java:738)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:657)
at org.apache.catalina.startup.Catalina.process(Catalina.java:178)
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:202)
____________________Reply Separator____________________
Subject: Re: Re[2]: war files. (tomcat 4.0 beta 7)
Author: [EMAIL PROTECTED]
Date: 8/14/2001 9:53 AM
On Tue, 14 Aug 2001, Jonathan Pierce wrote:
>
> >>Use "%CATALINA_HOME%\common\lib" if you want a JAR
> >>file visible to both applications *and* Catalina internal classes (which
> >>is rarely necessary).
>
> What about servlets that load at startup? Which directory does Catalina
search?
> For servlets that load at startup, will Catalina find servlet classes in war
> files in the webapps folder? This didn't work for me.
>
Servlets that load at startup are loaded from the webapp class loader
(along with all other servlets, filters, and application event listeners),
which checks things in the following order:
/WEB-INF/classes of your web-app
/WEB-INF/lib/*.jar of your web-app
$CATALINA_HOME/lib
$CATALINA_HOME/common/lib
System class loader (configured in catalina.sh or catalina.bat
from a predefined CLASSPATH)
$JAVA_HOME/jre/lib/ext (i.e. the system extensions directory)
Java runtime classes
If you deploy a WAR file into the webapps folder, one of two things will
happen:
* The WAR will be unpacked into a corresponding directory
and that directory will be used (if the directory already
exists, unpacking will *not* happen, so delete the directory
if you are redeploying an old WAR).
* If you have 'unpackWARs="false"' in the <Context> entry
for this webapp, the application will be run directly
from the WAR.
but the same loading order still works either way. I use load-on-startup
all the time on Tomcat with Struts-based apps (the controller servlet is
configured this way) and it works fine for me. You might want to check
the log files ($CATALINA_HOME/logs/*) to see exactly what problem is being
encountered, so we can figure out what is going on.
Craig
PS: Note that there are some Java classes which will work if you put them
in /WEB-INF but fail if loaded from $CATALINA_HOME/lib. The key issue is
if this class needs to create an object of a class that is inside your
webapp. When you put classes in $CATALINA_HOME/lib and try to reference
one of your webapp class names, they are not visible.