Bug 30762 - destroy method in servlet called before contextDestroyed method in ServletContextListener class.
Summary: destroy method in servlet called before contextDestroyed method in ServletCon...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Unknown (show other bugs)
Version: 5.5.17
Hardware: PC All
: P2 normal with 2 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 39038 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-08-19 19:17 UTC by David L. Diehl
Modified: 2006-12-24 19:06 UTC (History)
1 user (show)



Attachments
A simple WAR showing this (writes to System.out) (2.79 KB, application/octet-stream)
2004-08-27 16:57 UTC, Yoav Shapira
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David L. Diehl 2004-08-19 19:17:12 UTC
I created an implementation of ServletContextListener and was expecting its 
contextDestroyed(ServletContextEvent event) method to be invoked AFTER the 
destroy() method of the single servlet for the web app.  The 2.4 servlet spec 
states:

public void contextDestroyed(ServletContextEvent sce)
  Notification that the servlet context is about to be shut down. All servlets 
and filters have been destroy()ed before any ServletContextListeners are 
notified of context destruction.


Using Tomcat 5.0.25 and 5.0.27, the servlet destroy() method was invoked AFTER 
the contextDestroyed() method, in violation of the spec.  I tried with and 
without <load-on-startup> in the web.xml to see if this made a difference, and 
it did not.

NOTE:  The order of calls on the initialization side was correct and as I 
expected.  The method contextInitialized(ServletContextEvent event) in my 
ServletContextListener class was called before the init() methods of my 
servlet (and filters).
Comment 1 Yoav Shapira 2004-08-27 16:56:41 UTC
Hmm, it seems you're right.  I'm attaching a WAR that shows this behavior.  I'm 
not sure how we haven't detected this in our tests and the Sun TCK tests.  I'll 
ask on tomcat-dev.
Comment 2 Yoav Shapira 2004-08-27 16:57:20 UTC
Created attachment 12549 [details]
A simple WAR showing this (writes to System.out)
Comment 3 Yoav Shapira 2004-08-28 12:50:32 UTC
Fix committed on TOMCAT_5_0 branch.
Comment 4 Michael Soubine Chun 2006-07-28 17:54:31 UTC
This bug seem to have revived in Tomcat 5.5.16 and currently present in Tomcat
5.5.17.
Comment 5 Mark Thomas 2006-09-07 02:07:24 UTC
This has been re-fixed in SVN.

Thanks for the report.
Comment 6 David L. Diehl 2006-12-24 19:06:52 UTC
*** Bug 39038 has been marked as a duplicate of this bug. ***