You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Caldarale, Charles R" <Ch...@unisys.com> on 2008/08/15 23:09:03 UTC

RE: How to tell Tomcat to use an additional classpath other thanweb-inf/classes?

> From: swimming_rabbit [mailto:swimming_rabbit2003@yahoo.ca]
> Subject: How to tell Tomcat to use an additional classpath
> other thanweb-inf/classes?
>
> Does anyone know of a way to tell Tomcat to use an additional
> classpath (other than WEB-INF/classes) when loading an application?

(The discussion below is based on Tomcat 6, since you didn't bother to tell us the version you're using.)

You can put the classes in Tomcat's lib directory, and they'll be handled by the common loader rather than the webapp loader.  If you don't want to pollute that directory, you can enable the shared loader in conf/catalina.properties and use whatever directory you want.

The downside of the above is that the classes do not come and go with the webapp, so that may introduce problems during redeployment if you don't stop and start Tomcat.

Alternatively, you can write a simple class loader that extends WebappLoader, specific to the webapp, to handle your additional directory.  You can specify this class loader with the loaderClass attribute of the <Loader> element nested inside the webapp's <Context> element.  Look here for some info:
http://tomcat.apache.org/tomcat-6.0-doc/config/loader.html

Tomcat already has an extension to WebappLoader that you might be able to use:
    org.apache.catalina.loader.VirtualWebappLoader
You specify the additional paths via the virtualClasspath attribute in your <Context> element.

 - 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