Bug 33463

Summary: Struts PlugIn.destroy() method not called when WebApp stopped in Tomcat 5.5.7
Product: Tomcat 5 Reporter: Kev Palfreyman <kap>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: normal CC: bjs, kap, mguillemot, omints, trajano
Priority: P2    
Version: 5.5.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Kev Palfreyman 2005-02-09 12:32:48 UTC
I have a Struts 1.1 application that has worked fine in Tomcat 4.1.x, 5.0.x, 
but does not function correctly under Tomcat 5.5.7.

Specifically, my Struts application registers a PlugIn class (which just 
implements the 2 methods of the interface, i.e. init() and destroy()).  The 
init() method is called just fine as the app is started, but the destroy() 
method is not called when the app is stopped.  We are using the Manager 
application to start and stop the web app.

This can be reproduced by simply adding a PlugIn implementation to the struts-
examples.war - see example plugin below.

Interestingly, the destroy method of a plain servlet IS called when the app is 
stopped (this is our workaround just now).  It would appear that when the 
Struts ActionServlet.destroyModules() method is called, it performs the 
Enumeration names = getServletContext().getAttributeNames();
This enumeration is empty, and hence it is unable to notify the plugin.

Hope this is detailed enough.

For reference, this is on Win XP SP2, JRE 1.5.0_01, Tomcat 5.5.7, Struts 1.1


Kev Palfreyman
Apama UK Ltd.

Example PlugIn:

From struts-config.xml:

	<plug-in className="ApamaDebugPlugIn"></plug-in>

import org.apache.struts.action.PlugIn;
import org.apache.struts.action.ActionServlet;
import javax.servlet.ServletException;
import org.apache.struts.config.ModuleConfig;

public class ApamaDebugPlugIn implements PlugIn {

	public void init(ActionServlet servlet, ModuleConfig config) throws 
ServletException {

	public void destroy() {
Comment 1 Remy Maucherat 2005-02-09 12:58:23 UTC
And where in the specification is it said that attribute removals are not
allowed to be done before (it used to be never, anyway). I am willing to make
the change, however, since I do not even see why notifications should be sent
when artificially "removing" attributes from the context when stopping a webapp.
This seems wrong to me.
Comment 2 Remy Maucherat 2005-02-09 13:30:59 UTC
This is now fixed, assuming my interpretation of the specification is right and
other developers accept my changes.
Comment 3 Mark Thomas 2005-02-13 20:56:15 UTC
And also ported back to TC4 where my same fix had created the same problem.
Comment 4 Mark Thomas 2005-03-05 22:03:08 UTC
*** Bug 33832 has been marked as a duplicate of this bug. ***
Comment 5 Remy Maucherat 2005-03-08 18:36:24 UTC
*** Bug 33909 has been marked as a duplicate of this bug. ***
Comment 6 Remy Maucherat 2005-03-24 14:41:25 UTC
*** Bug 34164 has been marked as a duplicate of this bug. ***