You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Glenn R. Golden" <gg...@umich.edu> on 2005/03/05 04:15:26 UTC

ServletContextListener problem

I'm using Spring 1.1.4 and Tomcat 5.5.7.  I have a webapp with a 
ServletContextListener based on Spring's ContextLoaderListener.

The problem I think I'm seeing is that when the listener's 
contextDestroyed() method is called, the ServletContextEvent's 
ServletContext's attributes have been emptied, all but one 
(org.apache.catalina.WELCOME_FILES).

Spring uses a servlet context attribute to store the root 
WebApplicationContext (wac) for the webapp when the context is 
initialized.  When contextDestroyed() is called, Spring attempts to 
find the wac in the attributes.  What I'm seeing is that since the 
attributes have been removed before this point, the wac is not located.

This leads to the initial problem I saw, that being the beans in the 
webapp's wac are not being shut down properly on Tomcat shutdown.

Does this sound about right?  Has anyone seen this happening in Spring?

Should the servlet context attributes be unbound before 
contextDestroyed() in the ServletContextListener is called?  Has anyone 
else seen this happen in Tomcat 5.5.7?

Is this a known problem, or is there some known condition that might 
lead to this?

Ah - I just tested the same webapp code in Tomcat 5.0.27, and when the 
contextDestroyed() is called, all the servlet context attributes are 
still there, including the one from Spring... and Spring happily closes 
down the beans in that wac.

So this appears to be a new behavior in Tomcat 5.5.7.  Is this change 
intentional, or accidental?

The Servlet Spec (2.4) does not seem say when the servlet context 
attributes get unbound, only that the listener gets the 
contextDestroyed() after all servlets and filters have been stopped.  
Perhaps this is unclear.  (Or I might have missed where this was 
specified).

Thanks for your help.

- Glenn

Glenn R. Golden, Sakai Architect
Sr. Systems Research Programmer, University of Michigan
ggolden@umich.edu


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: ServletContextListener problem

Posted by Mark Thomas <ma...@apache.org>.
This is bug 33463 that has been fixed in CVS and is included in 5.5.8

Mark

Glenn R. Golden wrote:
> I'm using Spring 1.1.4 and Tomcat 5.5.7.  I have a webapp with a 
> ServletContextListener based on Spring's ContextLoaderListener.
> 
> The problem I think I'm seeing is that when the listener's 
> contextDestroyed() method is called, the ServletContextEvent's 
> ServletContext's attributes have been emptied, all but one 
> (org.apache.catalina.WELCOME_FILES).
> 
> Spring uses a servlet context attribute to store the root 
> WebApplicationContext (wac) for the webapp when the context is 
> initialized.  When contextDestroyed() is called, Spring attempts to find 
> the wac in the attributes.  What I'm seeing is that since the attributes 
> have been removed before this point, the wac is not located.
> 
> This leads to the initial problem I saw, that being the beans in the 
> webapp's wac are not being shut down properly on Tomcat shutdown.
> 
> Does this sound about right?  Has anyone seen this happening in Spring?
> 
> Should the servlet context attributes be unbound before 
> contextDestroyed() in the ServletContextListener is called?  Has anyone 
> else seen this happen in Tomcat 5.5.7?
> 
> Is this a known problem, or is there some known condition that might 
> lead to this?
> 
> Ah - I just tested the same webapp code in Tomcat 5.0.27, and when the 
> contextDestroyed() is called, all the servlet context attributes are 
> still there, including the one from Spring... and Spring happily closes 
> down the beans in that wac.
> 
> So this appears to be a new behavior in Tomcat 5.5.7.  Is this change 
> intentional, or accidental?
> 
> The Servlet Spec (2.4) does not seem say when the servlet context 
> attributes get unbound, only that the listener gets the 
> contextDestroyed() after all servlets and filters have been stopped.  
> Perhaps this is unclear.  (Or I might have missed where this was 
> specified).
> 
> Thanks for your help.
> 
> - Glenn
> 
> Glenn R. Golden, Sakai Architect
> Sr. Systems Research Programmer, University of Michigan
> ggolden@umich.edu
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org