You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Glenn Nielsen <gl...@voyager.apg.more.net> on 2001/01/06 03:34:21 UTC

Re: cvs commit: jakarta-tomcat/src/share/org/apache/jasper/compiler Compiler.java

"Scott M. Stirling" wrote:
> 
> On 05 Jan 2001 16:35:09 -0800, Hans Bergsten wrote:
> > "Scott M. Stirling" wrote:
> > > 1. Doesn't it seem a bit sloppy to leave a bunch of classes loaded that
> > > will never get dumped unless the server is shutdown?  Just a matter of
> > > elegance, I suppose.
> 
> [Hans Bergsten]
> 
> > Yes, it does. But AFAIK there's no way you can just unload a class
> > from the JVM; you would have to drop the class loader for the
> > context and reload all classes that are still valid. That doesn't
> > seem like the right thing to do in this situation IMHO.
> 
> It depends how class loading in Tomcat works.  I'm familiar with JRun
> 3.0, which works like this (I'm not giving away any family secrets, this
> stuff is documented in various places in Allaire docs):
> 
> - servlets & JavaBeans (even those called by JSPs) - loaded by a
> classloader with web-app scope.  If a single servlet changes, the whole
> web-app's classloader is dumped so the servlet can be dynamically
> reloaded.  No need to actively reload the other classes that got dumped
> with the classloader.  They'll be reloaded as needed when requests come
> in for them.
> 
> - JSPs are each loaded in their own classloader.  So if a JSP is changed
> and reloaded, the old classloader is dumped and a new one created.
> JavaBeans are delegated to the web-app classloader, for whatever reason.
> 
> All this may change in future versions, when JRun reloads tag handlers
> dynamically.  I have no idea how Tomcat handles these classloader
> issues, but it would be interesting to hear about if anyone can distill
> it briefly.
> 

Tomcat has a webapp classloader and Jasper has a class loader for JSP pages.
The webapp classloader is caching everything loaded from  the WEB-INF/classes 
or WEB-INF/lib directories.

Since Jasper is running within the web app, if the webapp context gets
reloaded, jasper gets reloaded.  Jasper IMHO is convoluted in the way
it loads JSP's. It munges the names when creating the java source and
class, and increments each of these files each time the JSP is compiled.
All those old versions of the classes stay resident in the Jasper
class loader and all the old java and class files clutter up the work dir.

While I am implementing the Java SecurityManager in Tomcat 4 I am also 
going to cleanup how Jasper loads classes so that there is one URLClassLoader 
per JSP page.  And that URLClassLoader gets reinstantiated when the JSP
page gets recompiled.

Regards,

Glenn

----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------