Nick Rothwell wrote:
> > The servlet instance itself, and the contents of its member variables, are
> > freed when the servlet engine calls the destroy() method of your servlet
> > and
> > releases the instance. For Apache JServ, that only happens when you shut
> > it
> > down, or when you have auto-reloading enabled and you modify one of the
> > servlet
> > classes.
> >
> [Nick Rothwell] I'd need to check closely, but there must be issues
> here if a reload is pending (a .class file has changed) but the servlet
> instance is still reachable as live data (say, it is referenced from data
> structures belonging to a session, or to another servlet, or a static). This
> must be an issue with class reloading in general; however, there's clearly
> an issue of whether destroy() can be called for a servlet object which then
> lives on because it's root-accessible?
>
Yes, there are certainly issues here. In the particular case of Apache JServ,
a custom class loader is used to load the servlets (because you cannot reload
classes loaded from the system class path), from the list of files and
directories you list in the "repositories" property of your zone. What happens
when an auto-reload is triggered is something like this:
* The destroy() method of all the active servlets is called
* The session data is all thrown away (which avoids
dangling references problems from this source)
* The class loader instance itself is thrown away
(thus making everything loaded by it "garbage").
* A new class loader instance is created
* Startup servlets are re-init'd
* Things continue as before
This solves some, but not all, of the issues. If you have references from a
system-classpath-loaded object to something loaded by the custom class loader,
weird and bad things can happen, like ClassCastException problems when the
fully qualified class name is the same. All of the hassle is courtesy of the
Java language rules regarding class loading, which are some of the most
convoluted and complicated things I've ever seen.
By the way, I would not recommend running a production application on Apache
JServ with auto-reloading enabled. Besides the potential for class cast
errors, there is a small performance penalty.
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html