tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: DBCP woes (running out of cursors).
Date Wed, 28 Oct 2009 16:47:54 GMT
Hash: SHA1


On 10/28/2009 12:21 AM, Elli Albek wrote:
> In terms of listeners, I saw that Tomcat executes requests while in
> the closing process.

That's a problem. What kind of listener are you using?

>> My understanding was that:
>> 1. Tomcat does not remove the connection pool
>> 2. Once the shutdown process has started, no new requests will be
>> handled by the currently-shutting-down context
>> Could these two items give the result you are observing? It's easy
>> enough to have your webapp close the DataSource (even though it's kinda
>> stupid that Tomcat doesn't do it for you).
> That depends on which shutdown it is. Understanding 2 is not correct
> from my debugging. You can have a sequence of:
> 1. Connection pool closed
> 2. Request sent to servlet

The documentation for ServletContextListener.contextDestroyed says:

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.

Assuming that servlets aren't being re-initialized to service new
requests, using a ServletContextListener ought to work in this case. I'm
happy to hear an explanation for why my assumption isn't true, but this
woul dbe my expectation. If your webapp is handling requests after the
ServletContextListener.contextDestroyed method is called, I would
consider that a violation of the servlet specification.

> If you want to add a listener that closes the pool, I would try
> adding tomcat lifecycle listener to the context. You can handle
> event Lifecycle.AFTER_STOP_EVENT. Try both listeners (web app and
> tomcat) and see which one runs last, and put the code there.

I'm guessing that Tomcat's listener would execute after the
ServletContextListener, since AFTER_STOP_EVENT indicates that the stop
has occurred, while the servlet-API listener says it "is about to be
shut down".

> Then the vision of J2EE designers of "separation of roles"
> materializes :)

Something tells me those guys didn't exactly invent the concept of
separation of roles.

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


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message