You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jonathan Pierce <Jo...@seagram.com> on 2001/08/14 18:37:44 UTC

Re[2]: war files. (tomcat 4.0 beta 7)

>>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.


____________________Reply Separator____________________
Subject:    Re: war files. (tomcat 4.0 beta 7)
Author: tomcat-user@jakarta.apache.org
Date:       8/14/2001 9:26 AM



On Tue, 14 Aug 2001, Pier P. Fumagalli wrote:

> James, Stuart at stuart.james@cazenove.com wrote:
> 
> > I have packaged my web application in a .war file and deployed it using
> > tomcat 4.0 beta 7.
> > 
> > perfect.
> > 
> > The only way I could get it to work was to copy my database jar files into
> > web-inf\lib, this would make my war file platform dependent as most database
> > vendors ship different jars for each operating system.
> > 
> > I tried them in the %CATALINA_HOME%\lib but that did not help.
> > 
> > suggestions / recommendations.
> 
> I _believe_... It's not %CATALINA_HOME%\lib, but %CATALINA_HOME%\common\lib
> 

No, "%CATALINA_HOME%\lib" is the right place for JARs that should only be
seen by applications.  Use "%CATALINA_HOME%\common\lib" if you want a JAR
file visible to both applications *and* Catalina internal classes (which
is rarely necessary).

Without knowing what the failure symptoms are when you put the JDBC
driver files into "%CATALINA_HOME%\lib", it's a little hard to debug "that
did not help".

> But I might be wrong...
> 
>     Pier
> 
> 
Craig



Re: Re[2]: war files. (tomcat 4.0 beta 7)

Posted by "Craig R. McClanahan" <cr...@apache.org>.

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.