File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes (Programmaticly) shutdown Tomact on java.lang.Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "(Programmaticly) shutdown Tomact on java.lang.Error" Watch "(Programmaticly) shutdown Tomact on java.lang.Error" New topic

(Programmaticly) shutdown Tomact on java.lang.Error

Chuck Norris

Joined: Mar 13, 2006
Posts: 1
Hi there,

we use tomcat and axis to write some webservices. i discovered that when i throw an java.lang.Error at any place (e.g. OutOfMemory Error) tomcat will not shutdown.
As far as i know Error's mean that something in the JVM went wrong and it should be shutdown/ended when an Error occurs.
What whould be the best way to manually shutdown tomcat if an Error occurs?
Maybe a callback tomcat offers or something like that?

Or something like
catch(Throwable t) {
if(t instanceof Error) {
org.apache...Bootstrap.main(new String[]{"stop"});
at the correct place?

thanks for any help

kind regards
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
I suppose you could use System.exit() but you may have to specifically set the security manager permission to call it.
Another alternative might be to throw an UnavailableException if you want to keep the rest of the server running. Trying to do anything after an OutOfMemoryError is pretty tricky, let us know what you come up with.
I agree. Here's the link:
subject: (Programmaticly) shutdown Tomact on java.lang.Error
It's not a secret anymore!