Tomcat + System.exit(0) will shutdown tomcat

Posted on 2003-03-01
Medium Priority
Last Modified: 2013-11-24
I have tomcat as my application server.

And there are nearly 10 context running under my tomcat.All are my application  which are very critical, and they can't go offline by any means. They should be online 24x7 running.

I have tested that in any of application i.e.,JSP or Servelt or Bean...
If that contains System.exit(0);  or System.exit(-1);
It will shut down tomcat.

I know that System.exit(0); is used for normal op abnoraml shutdown of JVM.

So there could be a senario of any person putting a small JSP with System.exit() and running that, it will shutdown my tomcat, that means all my application will go offline and i have to start my tomcat again.

And there could be another senario also the user putting the servlet or JSP in a startup servlet of tomcat, so whenever a tomcat is started, after that my context will comeup and startup servlet will be invoked and it contains System.exit(); and this will shutdown tomcat.

Is there anyway to stop that...means not accepting System.exit(0) instruction from any context running under tomcat?

could anyone help out with this.
Question by:vijay_trina
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 86

Accepted Solution

CEHJ earned 200 total points
ID: 8048152
Assuming that your interpretation of the effects of System.exit is correct (i'm not sure about this) i think you might be able to install a SecurityManager and disallow an exit in its checkExit method

Expert Comment

ID: 9058990
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
LVL 35

Expert Comment

ID: 9677827
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept CEHJ's comment as answer.

Please leave any comments here within the next seven days.


EE Cleanup Volunteer

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question