tomcat-users mailing list archives

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

Andrew,

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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8xhMEACgkQ9CaO5/Lv0PBXCgCgmM81JJasiDH1rD3lx5yHJTa6
8dsAnii8qNVXOpPbSVNJCfRGnZmPoyV/
=Xsi4
-----END PGP SIGNATURE-----

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


Mime
View raw message