You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Rutherford, Michael" <Mi...@cba.com.au> on 2007/02/23 15:50:42 UTC

Determining the complete classpath for a web app in Tomcat 5.5

I am attempting to find a (preferably simple :-) way to find out the
complete classpath for a web app. 

 

I can use the System property "java.class.path" which returns a list of
the jars and dirs from the system classpath, along with the common lib
and classes and the shared lib and classes. It does not however list the
jars found in the WEB-INF\lib directory.

 

One potential solution would be to deploy all classes/jars to the common
library but that idea gives me hives. Another solution would be to
determine the classes/jars using file scanning which isn't much better.
I don't want to go with a solution that requires separate maintenance to
continue working so I don't want to add a property file or similar.
Overriding the class loaders to provide the required detail is doable
but I don't want to change the underlying Tomcat code (maybe I can use
reflection to access a private variable or something, which is still not
good but is better than changing Tomcat at least).

 

Michael Rutherfurd


************** IMPORTANT MESSAGE *****************************       
This e-mail message is intended only for the addressee(s) and contains information which may be
confidential. 
If you are not the intended recipient please advise the sender by return email, do not use or
disclose the contents, and delete the message and any attachments from your system. Unless
specifically indicated, this email does not constitute formal advice or commitment by the sender
or the Commonwealth Bank of Australia (ABN 48 123 123 124) or its subsidiaries. 
We can be contacted through our web site: commbank.com.au. 
If you no longer wish to receive commercial electronic messages from us, please reply to this
e-mail by typing Unsubscribe in the subject line. 
**************************************************************



RE: Determining the complete classpath for a web app in Tomcat 5.5

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Rutherford, Michael [mailto:Michael.Rutherford@cba.com.au] 
> Subject: Determining the complete classpath for a web app in 
> Tomcat 5.5
> 
> I am attempting to find a (preferably simple :-) way to find out the
> complete classpath for a web app. 

Not sure why you want to do this, but in any event, first Read The Fine
Manual:
http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html

If you have access to any Class object for the web app, you can get its
ClassLoader object.  Assuming you're using Tomcat's standard
WebappClassLoader, this is a subclass of URLClassLoader, so it has a
getURLs() method that can be used to retrieve the paths it processes.
You can follow the getParent() chain of class loaders and do the same
thing all the way up to the system class loader.

 - 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