This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

(Programmaticly) shutdown Tomact on java.lang.Error  RSS feed

 
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
 
Author and all-around good cowpoke
Posts: 13078
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
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!