tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Listener Shutdown Order?
Date Wed, 14 Nov 2007 17:43:12 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jim,

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
destroyed:

"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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFHOzOv9CaO5/Lv0PARAn3pAJ9ObkpOysp3n9nS7JW50oS8EzcbEACXZrOB
1uiI3HXLQQkA8nL2H4mgmg==
=lF29
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message