Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Graceful shutdown of Tomcat - How?
Graceful shutdown of Tomcat - How? [message #522184] Sat, 20 March 2010 22:50 Go to next message
Mike  is currently offline Mike
Messages: 1
Registered: March 2010
Junior Member
Hi,

I have Tomcat running from within Eclipse using WTP and can control startup and shutdown from the Servers View. However, when I click on Stop for a running Tomcat, the server shuts down but doesn't seem to do so gracefully, i.e. my 'listener-class' specified in 'web.xml' never gets to execute its 'contextDestroyed()' method (at least, I am not seeing my logs in the log file).

When I run the same code in a standalone Tomcat installation, calling the 'startup.sh' and 'shutdown.sh' scripts manually from a console, the contextDestroyed() method is executed and I see my logging statements in the logfile.

Is there a way to shutdown Tomcat gracefully from within WTP so that my listeners get to destroy themselves?

Thanks
Re: Graceful shutdown of Tomcat - How? [message #522365 is a reply to message #522184] Mon, 22 March 2010 13:43 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry Isaacs
Messages: 1308
Registered: July 2009
Senior Member
Mike wrote:
> Hi,
>
> I have Tomcat running from within Eclipse using WTP and can control
> startup and shutdown from the Servers View. However, when I click on
> Stop for a running Tomcat, the server shuts down but doesn't seem to do
> so gracefully, i.e. my 'listener-class' specified in 'web.xml' never
> gets to execute its 'contextDestroyed()' method (at least, I am not
> seeing my logs in the log file).
>
> When I run the same code in a standalone Tomcat installation, calling
> the 'startup.sh' and 'shutdown.sh' scripts manually from a console, the
> contextDestroyed() method is executed and I see my logging statements in
> the logfile.
>
> Is there a way to shutdown Tomcat gracefully from within WTP so that my
> listeners get to destroy themselves?
>
> Thanks

Startup and shutdown aren't really any different within Eclipse and
using external batch scripts. What is different is that within Eclipse,
the separate Tomcat instance may be configured a little differently from
the installed version. For details see the Tomcat FAQ[1]. Logging is
one of the areas that can easily differ. Probably the easiest way to
verify if your context listener is being called is to put a breakpoint
in the contextInitialized() and contextDestroyed() methods, then run in
debug mode and see if the breakpoints are hit.

Cheers,
Larry



[1] http://wiki.eclipse.org/WTP_Tomcat_FAQ
Re: Graceful shutdown of Tomcat - How? [message #780547 is a reply to message #522365] Wed, 18 January 2012 14:55 Go to previous messageGo to next message
Matteo TURRA is currently offline Matteo TURRA
Messages: 4
Registered: July 2009
Junior Member
Why there is no option to shutdown tomcat gracefully using SHUTDOWN command on "Tomcat admin port" (default 8005), like shutdown.bat/.sh does?
Re: Graceful shutdown of Tomcat - How? [message #780556 is a reply to message #780547] Wed, 18 January 2012 15:47 Go to previous message
Larry Isaacs is currently offline Larry Isaacs
Messages: 1308
Registered: July 2009
Senior Member
On 1/18/2012 9:55 AM, Matteo TURRA wrote:
> Why there is no option to shutdown tomcat gracefully using SHUTDOWN
> command on "Tomcat admin port" (default 8005), like shutdown.bat/.sh does?
>

In the Servers view, the "Stop" context menu command and the "Stop the
server" icon effectively do the same thing as shutdown.bat. After
executing one of these, you can look in the Debug view of the Debug
perspective and find the "Tomcat server launch" which asked Tomcat to
terminate (i.e. calls the org.apache.catalina.startup.Bootstrap class
with a "stop" command which is what shutdown.bat does).

Cheers,
Larry
Previous Topic:Republish does not work (static resources)
Next Topic:Referenced Jar Does not exist
Goto Forum:
  


Current Time: Mon Oct 20 10:01:37 GMT 2014

Powered by FUDForum. Page generated in 0.01647 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software