[Advanced-java] class loaders and appservers and unloading apps

Rob Helmer robert at roberthelmer.com
Mon Sep 22 06:22:32 2003


On Sun, Sep 21, 2003 at 02:44:53PM -0500, Hanasaki JiJi wrote:
> How is it that an appserver tomcat/bea/jboss.... can kill an app and 
> unload it even if it has threads running to object instances that are 
> inuse and not ready for garbage collection?
> -- 


I believe it is because you run Servlets and EJBs inside App servers, which
must follow a stricter API, and not actual Java applications (e.g. a 
command line utility with just a "main" method).

Servlets must have an init() method, destroy() method and so on.

JSPs are basically Servlets when it comes down to it, and EJBs have
a similar API wherein they are invoked and destroyed by the App server.

The App server also handles garbage collection for all running
Servlets/EJBs; for instance, there is just one garbage collector per
App server instance, rather than per-servlet/per-EJB.
It also handles thread allocation.