views:

22

answers:

1

I have a situation where I have a bunch of classloader instances but no way of knowing what they are for- I know some are for the webapp Is there a way to tell which webapp they belong to ? These are all instances of the same class type btw -not that it makes a difference... Thanks!

+1  A: 

I'm not aware of any property that you could use to identify the webapp classloaders as far as a context goes, but you could walk through each of your contexts looking at their associated classloaders and find matches that way.

Mondain
That is a good idea, but there is no direct reference to a classloader in the servletcontext (is that what you meant ?). I dont want to pollute my web-apps by writing code to look for thread context classloaders (if that is indeed the same as the classloader associated with the webapp...) Is there anyway to get the webapp associated classloader from the webapp context ?
unmaskableinterrupt
If you are using Tomcat, you can access the webapp class loader with context.getLoader() and you can also access the parent classloader from within that same context like so context.getParentClassLoader(). By context I mean org.apache.catalina.Context which should be available within any Servlet class.
Mondain