> -----Original Message-----
> From: Caldarale, Charles R [mailto:chuck.caldar...@unisys.com]
> Sent: Tuesday, February 07, 2012 1:39 PM
> To: Tomcat Users List
> Subject: RE: Shutdown Hooks not firing when tomcat is shutdown from
> within a webapp
> 
> > From: Andrew Kujtan [mailto:akuj...@evertz.com]
> > Subject: Shutdown Hooks not firing when tomcat is shutdown from
> within a webapp
> 
> > OS: Windows 7  32bit
> > Ver.: Apache Tomcat/7.0.25
> > Jvm: 1.6.0_14-b08
> 
> Thanks for that.
> 
> > I am attaching a shutdown hook from within my webapp to log
> > some info after tomcat shuts down,
> 
> That really doesn't sound like a good idea at all.  I would think you
> should be using a ServletContextListener.
Unfortunately the actions need to happen after tomcat has shutdown, not
just my webapp.
> 
> > Can anyone tell me how to programmatically shut down tomcat
> > such that the hooks will still fire?
> 
> There's no real provision for doing so, since that's not a decision a
> webapp should be making. 

I agree, but I don't have a choice, boss says it must kill itself if
some scenario happens.

> There's always System.exit()...
> 
When I call System.exit() tomcat doesn't actually shutdown, it looks
like it just is deadlocking or something as I am getting a timeout on
the call that runs it. On the bright side System.exit() does trigger the
shutdown hook to be called, even though the server doesn't shut down, it
just becomes unresponsive but the process remains and is still bound to
all of its ports.

If I call both,

org.apache.catalina.startup.Bootstrap.main(new String[] { "stop"});
System.exit(0);

Tomcat shuts down, and my hook gets called, but I don't know how
ridiculous I want to take this already hacky thing...

Probably stupid question, but is calling System.exit() from a webapp
supposed to be able to kill tomcat?

>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE
> PROPRIETARY MATERIAL and is thus for use only by the intended
> recipient. If you received this in error, please contact the sender
and
> delete the e-mail and its attachments from all computers.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to