This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

(Programmaticly) shutdown Tomact on java.lang.Error

 
Chuck Norris
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
-chuck
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic