How to exit tomcat if web app throws exception?

2007-04-27 Thread Si'mon

For development boxes, I want tomcat to exit if an exception is thrown in a
specific .war (web application).  After exiting it will print the exception
and not go any further.

Is there any way to do this (configuration) or any way to incorporate this
into the web application?

thanks


Si'mon
-- 
View this message in context: 
http://www.nabble.com/How-to-exit-tomcat-if-web-app-throws-exception--tf3660087.html#a10227191
Sent from the Tomcat - User mailing list archive at Nabble.com.


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to exit tomcat if web app throws exception?

2007-04-27 Thread Rashmi Rubdi

On 4/27/07, Si'mon [EMAIL PROTECTED] wrote:


For development boxes, I want tomcat to exit if an exception is thrown in a
specific .war (web application).  After exiting it will print the exception
and not go any further.

Is there any way to do this (configuration) or any way to incorporate this
into the web application?


I haven't written code to shutdown Tomcat from a program.

One thing that comes to mind is calling shutdown.bat / shutdown.sh
from the location of the catch for that exception.

Also, there may be other better ways to accomplish this.

I think it's a bad idea to shutdown tomcat every time an exception
occurs. Some of the exceptions do get logged in the logs folder under
Tomcat's folder whether Tomcat is shutdown or not, additionally you
can use tools like Log4J to log your own exceptions.



thanks


Si'mon
--


-Regards
Rashmi

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to exit tomcat if web app throws exception?

2007-04-27 Thread Bill Barker

Rashmi Rubdi [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On 4/27/07, Si'mon [EMAIL PROTECTED] wrote:

 For development boxes, I want tomcat to exit if an exception is thrown in 
 a
 specific .war (web application).  After exiting it will print the 
 exception
 and not go any further.

 Is there any way to do this (configuration) or any way to incorporate 
 this
 into the web application?


If you are running with a SecurityManager, then you are SoL.  Otherwise, if 
you don't care about a clean shutdown, then a simple
System.exit(0);
will do the trick.

 I haven't written code to shutdown Tomcat from a program.

 One thing that comes to mind is calling shutdown.bat / shutdown.sh
 from the location of the catch for that exception.

 Also, there may be other better ways to accomplish this.


If you are not running from 'jsvc' or embedded, and using the default 
configuration, then (copied from Catalina.java):
Socket socket = new Socket(127.0.0.1, 8005);
OutputStream stream = socket.getOutputStream();
String shutdown = SHUTDOWN;
for (int i = 0; i  shutdown.length(); i++)
stream.write(shutdown.charAt(i));
stream.flush();
stream.close();
socket.close();



 I think it's a bad idea to shutdown tomcat every time an exception
 occurs. Some of the exceptions do get logged in the logs folder under
 Tomcat's folder whether Tomcat is shutdown or not, additionally you
 can use tools like Log4J to log your own exceptions.


 thanks


 Si'mon
 --

 -Regards
 Rashmi

 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

 




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]