tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 42172] - Classloader leak
Date Thu, 19 Apr 2007 17:47:51 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42172>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42172


kgross@dor.state.wi.us changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |




------- Additional Comments From kgross@dor.state.wi.us  2007-04-19 10:47 -------
I've been looking at this further and I really think there's something wrong
here.  What I find wrong comes down to the fact that the variable causing the
cross reference (ApplicationDispatcher.log) is a static.  How does a static
variable allow for the app server to do per webapp logging.  

So I created 2 identical webapps.  They have a single servlet that simply
dispatches to a JSP.  I added code to the dispatch that looks at the classloader
for the servlet, request dispatcher and the log of the request dispatcher.  I
then hit webapp 1 and then webapp2.  I reloaded both apps and did the same again.

The code and output is included below.  Basically the ApplicationDispatcher has
a log loaded by the classloader for the first webapp I hit.  After a reload the
log is still the log loaded by that first webapp classloader and that
classloader is marked not started.  In addition, the parent instance variable
defined in WebappClassLoader is null.

I'm not particularly knowledgeable about Tomcat yet but it would seem that using
classes loaded from one webapp while servicing the request for another webapp is
bad. And continuing to use classes loaded by a classloader that's been stopped
would seem a very bad idea.

=========== Code inserted into the servlet ===================
ServletContext sc = null;
RequestDispatcher rd = null;

sc = getServletContext();
rd = sc.getRequestDispatcher(uri);
		
Object log = getField(rd, "log");
ClassLoader loaderC = rd.getClass().getClassLoader();
System.out.println(loaderC);
ClassLoader loaderA = this.getClass().getClassLoader();
System.out.println(loaderA);
ClassLoader loaderB = log.getClass().getClassLoader();
System.out.println(loaderB);
		
System.out.println("servlet loader " + (loaderA == loaderB ? "equals" : "does
not equal") + " RequestDispatcher's log loader");
System.out.println("servlet loader " + (loaderA == loaderC ? "equals" : "does
not equal") + " RequestDispatcher loader");
System.out.println("RequestDispatcher's log loader " + (loaderB == loaderC ?
"equals" : "does not equal") + " RequestDispatcher loader");



================= Output immediately after the server comes up =======
WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@31f2a7

WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@31f2a7

servlet loader equals RequestDispatcher's log loader
servlet loader does not equal RequestDispatcher loader
RequestDispatcher's log loader does not equal RequestDispatcher loader
org.apache.catalina.loader.StandardClassLoader@5e55ab
WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@31f2a7

WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@31f2a7

servlet loader does not equal RequestDispatcher's log loader
servlet loader does not equal RequestDispatcher loader
RequestDispatcher's log loader does not equal RequestDispatcher loader



============== Output after reloading both of the applications =======
org.apache.catalina.loader.StandardClassLoader@5e55ab
WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@31f2a7

WebappClassLoader
  delegate: false
  repositories:

servlet loader does not equal RequestDispatcher's log loader
servlet loader does not equal RequestDispatcher loader
RequestDispatcher's log loader does not equal RequestDispatcher loader
org.apache.catalina.loader.StandardClassLoader@5e55ab
WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@31f2a7

WebappClassLoader
  delegate: false
  repositories:

servlet loader does not equal RequestDispatcher's log loader
servlet loader does not equal RequestDispatcher loader
RequestDispatcher's log loader does not equal RequestDispatcher loader



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message