tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Listener Shutdown Order?
Date Wed, 14 Nov 2007 17:43:12 GMT
Hash: SHA1


Jim Garrison wrote:
> When starting up, Listeners are started before load-on-startup servlets,
> so we use this mechanism to initialize Spring.

So you are using a ServletContextListener, right?

> On shutdown, Tomcat seems to shutdown listeners BEFORE the servlets.
> This results in the Spring context being discarded while it is still
> needed.  If context listeners start before servlets, shouldn't the
> listeners be shutdown AFTER the servlets?

The Servlet Specification covers this a bit in section 10.3.4 (of 2.4...
I can't seem to find the actual PDF for the 2.5 spec), but does not
specify that the context must be shut down before the listeners are
notified. (In fact, it doesn't make any sense that it would happen this
way... the listeners exist within the context, so terminating the
context and then notifying the listeners is a bit of an odd notion).

The javadoc for ServletContextListener.contextDestroyed clearly
indicates that the message is sent /before/ the context is actually

"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." (Emphasis
added by me).

Note that the implication of this documentation is that the context will
not be serving any more requests by the time your listener is notified,
do you don't really have to worry about Spring not being available to
your servlets and stuff, 'cause they've already been taken out of service.

Were you experiencing a problem, or just anticipating one?

Hope that helps,
- -chris

Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla -


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message