Bug 33463 - Struts PlugIn.destroy() method not called when WebApp stopped in Tomcat 5.5.7
Summary: Struts PlugIn.destroy() method not called when WebApp stopped in Tomcat 5.5.7
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.5.7
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 33832 33909 34164 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-02-09 12:32 UTC by Kev Palfreyman
Modified: 2005-03-24 05:41 UTC (History)
5 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 
following:
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


Cheers,

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 {
		System.out.println("ApamaDebugPlugin.init()");
	} 


	public void destroy() {
		System.out.println("ApamaDebugPlugin.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. ***