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.


Reply via email to