If possible, you may consider a monitor or cron in a separate process. It checks the state of the servlet by making a HTTP GET to it; depending on response, it could initiate the SHUTDOWN command to Tomcat.

COHEN, STEVEN M (ATTSI) wrote:
Yeah, that was what I thought.  Apps aren't supposed to do that.  But in my
case where there is a one-to-one between Tomcat and my app, it's okay.  In
fact, I also need to launch Tomcat with a special script that sets a number
of parameters required by my app, because the one of the systems I'm
depending on requires it to be just so. This whole contraption has a real Rube Goldberg feel to it, but dang,
it works just fine with System.exit(0).  Oh well, as they say, rules were
meant to be broken.

Steve
-----Original Message-----
From: Len Popp [mailto:[EMAIL PROTECTED] Sent: Friday, August 22, 2008 2:46 PM
To: Tomcat Users List
Subject: Re: I WANT Tomcat to die when a given servlet fails to initialize

There isn't a clean way for webapps to shut down the server because they're
not really supposed to do that. :-)

If you thrown an UnavailableException from a servlet's init method, that
servlet won't run.
If you do app initialization in a ServletContextListener and throw an
exception from the contextInitialized method, the webapp won't run.
But in both these cases the Tomcat server keeps running.
--
Len



On Fri, Aug 22, 2008 at 15:08, COHEN, STEVEN M (ATTSI) <[EMAIL PROTECTED]>
wrote:
Yeah, that would work :-).  I guess I was looking for something a bit
more,
well, graceful.

-----Original Message-----
From: Lucas Galfaso [mailto:[EMAIL PROTECTED]
Sent: Friday, August 22, 2008 1:55 PM
To: Tomcat Users List
Subject: Re: I WANT Tomcat to die when a given servlet fails to initialize

try {
 [...]
} catch (Exception e) {
 System.exit(0);
}

??

:-)


-lg


On Fri, Aug 22, 2008 at 3:42 PM, COHEN, STEVEN M (ATTSI) <[EMAIL PROTECTED]>
wrote:
This may seem like an odd request and I'm sure it is nonstandard, but
it nonetheless something I'd like to be able to do.  We have an
instance of Tomcat running.  It runs one application.  This
application is NOT an application serving content over the www.  It is
basically a straight java application running inside of a web server.
The reason it runs in a Web server is because there is one subsidiary
use case that uses HTTP Gets to fire actions in the application via a
servlet.  No other applications are served off this web server.

The non-web application's "main()" is the servlet's init().  If this
servlet cannot initialize there is no point to keeping Tomcat running
and it would in fact make monitoring easier if it were not running.

Is there any easy way to achieve this in Tomcat?

---------------------------------------------------------------------
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]



--
Regards

Gabe Wong
NGASI AppServer Manager
JAVA AUTOMATION and SaaS Enablement for Cloud Computing
http://www.ngasi.com
NEW! FREE Developer account for Hosted version on Amazon EC2


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

Reply via email to