DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7971>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7971 Problems with stop() and reload() in StandardContext Summary: Problems with stop() and reload() in StandardContext Product: Tomcat 4 Version: 4.0.3 Final Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Catalina AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] The current implementation of StandardContext prevents our application from shutting down cleanly during a reload or stop. There are two problems that are described below and fixed by the attached patch (which needs competent review!). 1) We use a ServletContextListener to free application wide resource when the context is shut down. At this point, we need access to context attributes to free all our resources. When Tomcat is shut down, all works well. However, when the context is reloaded, all context attributes are cleared before the listener's contextDestroyed method is called (see source of StandardManager.reload()). The fix is simple: The call to listenerStop() has to be put before the place where the context attributes are cleared. However, I don't know which side effects this may have, so this needs an expert review. As a side note, I think it is completely spec conformant to access context attributes in the contextDestroyed event (quote from Servlets 2.3 JavaDoc: "Notification that the servlet context is ***about to be*** shut down."). 2) We need to free resources and save some settings when a session is destroyed (note that we have disabled persistent sessions). To do this, we need a) access to session attributes and b) access to resources within our app (via ServletContext.getResourceAsStream()). Point a) prevents us from using an HttpSessionListener, since the spec says "Notification that a session *** was *** invalidated". Thus, we use an HttpSessionBindingListener. However, the current implementation of StandardContext shuts down the session manager too early in both stop() and reload() methods. As a result, ServletContext.getResourceAsStream() returns null at this stage. The fix seems simple enough: Stop the session manager at a point where access to a webapp's resources is still possible. I think it is reasonable to assume that these resources are available within a valueUnbound() event. However, I'm not sure if I picked the right place for shutting down the manager in my patch. I don't know enough about Catalina's internal architecture to tell what the other effects (besides solving my problem) might be. The patch is relative to the nightly sources of 2002-04-09. I've tested it with and without persistent sessions, and it seems to work fine. Could a committer please have a look and apply the fix if it seems reasonable (or tell me what is wrong with it)? This is a high priority issue for us since it prevents us from using the reload feature and also from shutting down our sessions cleanly when Tomcat is shutdown. Thanks in advance -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>