tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Shutdown Hooks not firing when tomcat is shutdown from within a webapp
Date Tue, 07 Feb 2012 20:08:33 GMT
Hash: SHA1


On 2/7/12 2:40 PM, Andrew Kujtan wrote:
> When I call System.exit() tomcat doesn't actually shutdown

That's weird.

> it looks like it just is deadlocking or something as I am getting
> a timeout on the call that runs it.

What does a thread dump show you?

> On the bright side System.exit() does trigger the shutdown hook to
> be called, even though the server doesn't shut down, it just
> becomes unresponsive but the process remains and is still bound to 
> all of its ports.

Again, that seems weird. Do you have some kind of deadlock occurring
in your shutdown code? It sounds like:

System.exit: calls your shutdown hook, JVM does not stop
Bootstrap.main({"stop"}): avoids your shutdown hook, JVM stops

Maybe you should check your shutdown hook. :)

> If I call both,
> org.apache.catalina.startup.Bootstrap.main(new String[] {
> "stop"}); System.exit(0);
> Tomcat shuts down, and my hook gets called, but I don't know how 
> ridiculous I want to take this already hacky thing...

It's a pretty ridiculous hack in any case, right?

> Probably stupid question, but is calling System.exit() from a
> webapp supposed to be able to kill tomcat?

Yes. It should kill the JVM, which should shut down everything. If you
want to protect your JVM from webapps that might call System.exit(),
then you need to run under a SecurityManager.

- -chris
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with Mozilla -


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

View raw message