Yes, but that's not really what Robert was asking.
The original question (as I read it) is really
* How can I find out what directories classes can be loaded from for a given
webapp.

I presume that if you call YourClassName.class.getClassLoader() for any
class inside
your webapp (eg from a servlet you have written and placed in
WEB-INF/classes)
then you will get the classloader which has embedded within it the
information
you require.

However, I can't see any ClassLoader methods that allow someone to query the
path that it will use when you call loadClass("someClass"). In fact, as
custom
classloaders don't have to use a CLASSPATH at all, it makes sense that there
is no such function in the ClassLoader interface.

ClassLoader, however, is just an abstract base class for the object that
will
actually be returned by YourClassName.class.getClassLoader. I think that
the class will *actually* be a java.net.URLClassLoader. So, why not try:

(a) write a servlet (eg ClasspathFinderServlet)
(b) in the servlet:
  ClassLoader cl = ClasspathFinderServlet.class.getClassLoader();
  try
  {
    URLClassLoader ucl = (URLClassLoader) cl;
    URL[] searchpath = ucl.getURLs();
    // print out the URL[] array
  }
  catch(CastException e)
  {
    system.err.println("oh well, that idea didn't work");
  }

In order to get a complete classpath, you might need to do the above for 
the parent of the classloader, and all parent classloaders up to the top
of the tree...

This is all theory - if it works, please let me know..

Cheers,

Simon

> -----Original Message-----
> From: Stubenrauch,Andreas [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, November 07, 2000 9:44 AM
> To:   '[EMAIL PROTECTED]'
> Subject:      RE: How can I see my webapps classpath?
> 
> AFAIK in Tomcat 3.x there is just one classpath for the entire tomcat
> (resp.
> for the JVM) 
> The webapps/foo/classes/ and webapps/foo/lib/ are not 'really' in the
> classpath. Files in there get loaded by an modified Tomcat-Classloader.
> 
> For short: the systemclasspath=your webapp classpath
> 
> Regards
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, November 06, 2000 9:28 PM
> > To: [EMAIL PROTECTED]
> > Subject: How can I see my webapps classpath?
> > 
> > 
> > I want to print out the classpath that's associated with my web app
> > not the system one but the one that tomcat is using for the web app
> > after it's seen classes and lib. Is this possible?
> > 
> > 

Reply via email to