This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat service stops abruptly !!!

 
Kirtikumar Puthran
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am sorry for posting this topic on this forum. I have posted this topic in the Apache/Tomcat forums....but seems no one is interested in answering this query over there. I will appreciate if someone atleast shows me a way so that I can venture out further.
I have a serious problem at hand. The tomcat service on our live production server has to be restarted every now and then, as it stops abruptly after a certain time.
Our application uses Apache as the web server and Tomcat as the servlet engine. Can someone please throw some light on this matter ? Can this problem be minimized upto a certain extent if not totally ? Are there any parameters to be set which improves the performance of tomcat.


TIA,
Kirtikumar Puthran
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Run a search through your source code for System.exit. If any of your code call this, it can take the Tomcat process down.
Another alternative is change the security policy to block it, but my preference is to fix the problem rather than hiding it.
A third option is that it is something else unrelated...
 
Kirtikumar Puthran
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
Thanks a lot for your response.
Certainly there are a lot of public classes in which System.exit(n) is written. But, then what is the alternative to this, say in case if a particular condition occurs, I want to stop the processing of that code....and I thought System.exit(1) was the way to do it.
How do I change this to do the intended task?
Rgds,
Kirtikumar Puthran :roll:
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what exceptions are for.
As a "rule of thumb", you should only ever consider calling System.exit in a "main" method. Everywhere else you should throw an exception instead.
This is especially important in a shared context such as a servlet container. One class unable to do its job should not stop all the others.
Everywhere you currently use System.exit, you should examine the code to see what strange situation caused you to put the System.exit in originally, and choose (or create) an appropriate exception to throw instead. This will serve two useful purposes: First, it will stop every unexpected situation from crashing the whole server; second it will generate a "stack trace" which can be printed, logged, emailed or passed back to the user, so that you can find and fix whatever made it fail in the first place.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!