You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by um...@comcast.net on 2007/11/15 18:34:17 UTC

Tomcat 6.0.x Classloader sequence


I understand that the webapp classloaders in Tomcat 6.0.x diverge from the delegation model
in first loading from the webapp before yielding to the commons class loader.

Is it possible for me to configure the webapp class loaders to load classes from a path
common to multiple webapps before loading from the webapp itself?

Our application suite is a collection of webapps and I need to locate the jar files shared by these
webapps in a path common to all the webapps comprising the application.

Tx,


/U

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat 6.0.x Classloader sequence

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
> Subject: RE: Tomcat 6.0.x Classloader sequence
> 
> > Is it possible for me to configure the webapp class 
> > loaders to load classes from a path common to multiple
> > webapps before loading from the webapp itself?
>
> Browsing through the Tomcat source does turn up something called
> VirtualWebappLoader; the comments therein indicate this is intended to
> provide what you want.
> 
> I couldn't actually get it to work, but it is intriguing...

With a little more playing around, I did get it to work.  Your webapps
will need a <Context> similar to the following:

<Context>
  <Loader className="org.apache.catalina.loader.VirtualWebappLoader"
          virtualClasspath="C:/dir/classes"/>
</Context>

I assume if you put this in conf/context.xml, it will apply to all
webapps.  Multiple locations can be given in the virtualClasspath
attribute by separating them with semicolons; each jar must be specified
separately.

Using the MBeans tab of JConsole, you can see the paths used by each
individual classloader; look in the Catalina -> Loader -> <appname> ->
<hostname> -> Attributes for classpath.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat 6.0.x Classloader sequence

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: uma_rk@comcast.net [mailto:uma_rk@comcast.net] 
> Subject: Tomcat 6.0.x Classloader sequence
> 
> Is it possible for me to configure the webapp class loaders 
> to load classes from a path common to multiple webapps before
> loading from the webapp itself?

I can't find anything in the docs that indicate this is directly
configurable, but it should be possible to extend WebappClassLoader and
add your own path.

Browsing through the Tomcat source does turn up something called
VirtualWebappLoader; the comments therein indicate this is intended to
provide what you want.  However, it also includes this note:

"This is not meant to be used for production. Its [sic] meant to ease
development with IDE's [sic] without the need for fully republishing
jars in WEB-INF/lib"

I couldn't actually get it to work, but it is intriguing...

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org