You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Thomas, Steve" <st...@vocollect.com> on 2013/03/14 17:00:19 UTC

Procrun and Tomcat service/OS shutdown on Windows

Hi -

Running Tomcat 7.0.23 or 7.0.37 (32 or 64-bit) installed as a service (either via service.bat or the exe installer) on a Windows 7 64-bit OS, we are seeing an issue where the Windows shutdown kills Tomcat before our webapp shutdown sequence has time to execute fully.  (Specifically, we just want to make sure our instance of HSQLDB shuts down correctly, otherwise corruption can ensue.)

Details:

Initially we were running with 32-bit Tomcat 7.0.23 and saw that our shutdown sequence was not being logged at all when one of our customers shut down his laptop.  It looked like the process was just being killed.  I found a commons-daemon/procrun bug and corresponding fix that seemed like it should address the issue, namely 

http://stackoverflow.com/questions/13578196/how-to-gracefully-shutdown-procrun/14150785#14150785

https://issues.apache.org/jira/browse/DAEMON-274 

I subsequently upgraded Tomcat to 7.0.36 (32-bit, zip) to get the updated commons-daemon (http://tomcat.apache.org/tomcat-7.0-doc/changelog.html), but to no avail.  I thought perhaps the 32-bit Tomcat/64-bit OS might be a disconnect, so I installed the 64-bit version, but got the same result.  In short, it looks like we're either doing something wrong with our code, or there's a new wrinkle in the OS-service handshaking, or the bug wasn't fixed correctly...maybe in that order.

Details below on how our code manifested the problem as well as other steps to reproduce.

Our database shutdown code is located in the destroy() function of a class implementing org.springframework.beans.factory.DisposableBean.  I added a Thread.sleep(5 min) call to reproduce it on my machine.  As long as I shut down the service through the Services panel on Windows, the shutdown sequence fully executes (and takes 5 min, as expected).  But if I just shut down Windows, the sequence is interrupted.  

(As an aside, I don't expect the shutdown to take anywhere near that long in practice, but wanted to make sure the problem manifested itself so that I could address the bug.  We are seeing this with a decent customer test machine, but I can't reproduce it on my machine w/o changes.)

Thinking it might be Spring, I moved the shutdown delay to a ServletContextListener. contextDestroyed() method.  Same effect.

I moved the delay again, and reproduced the same problem in a standalone servlet that overrides HttpServlet.destroy().  I've posted the code at the link below:

http://pastebin.com/yYgrQ2sE

This is the output recorded in the stdout log file for an OS shutdown, and then a shutdown of the service by hand.  We, of course, favor the second. :-)

2013-03-14 10:05:40 Commons Daemon procrun stdout initialized
StatusServlet.init()
Entering StatusServlet.destroy()
Simulating long shutdown sequence.

2013-03-14 10:12:29 Commons Daemon procrun stdout initialized
StatusServlet.init()
Entering StatusServlet.destroy()
Simulating long shutdown sequence.
Simulation complete--sequence finished.
Exiting StatusServlet.destroy()

Can we guarantee that Windows won't just kill our Tomcat process and potentially corrupt our database?  That's the question.

I'd be grateful for some help on this.  Thanks for your time and attention.

Steve T
This message is intended only for the named recipient. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action based on the contents of this information is strictly prohibited.


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


RE: Procrun and Tomcat service/OS shutdown on Windows

Posted by "Thomas, Steve" <st...@vocollect.com>.
-----Original Message-----
From: Harris, Jeffrey E. [mailto:Jeffrey.Harris@ManTech.com] 
Sent: Thursday, March 14, 2013 4:11 PM
To: Tomcat Users List
Subject: RE: Procrun and Tomcat service/OS shutdown on Windows



> -----Original Message-----
> From: Konstantin Kolinko [mailto:knst.kolinko@gmail.com]
> Sent: Thursday, March 14, 2013 4:01 PM
> To: Tomcat Users List
> Subject: Re: Procrun and Tomcat service/OS shutdown on Windows
>
> 2013/3/14 Thomas, Steve <st...@vocollect.com>:
> > Hi -
> >
> > Running Tomcat 7.0.23 or 7.0.37 (32 or 64-bit) installed as a 
> > service (either via service.bat or the exe installer) on a Windows 7 
> > 64-bit OS, we are seeing an issue where the Windows shutdown kills 
> > Tomcat before our webapp shutdown sequence has time to execute fully.
> > (Specifically, we just want to make sure our instance of HSQLDB 
> > shuts down correctly, otherwise corruption can ensue.)
> >
> > Details:
> >
> > Initially we were running with 32-bit Tomcat 7.0.23 and saw that our 
> > shutdown sequence was not being logged at all when one of our 
> > customers shut down his laptop.  It looked like the process was just 
> > being killed.  I found a commons-daemon/procrun bug and 
> > corresponding fix that seemed like it should address the issue, 
> > namely
> >
> > http://stackoverflow.com/questions/13578196/how-to-gracefully-
> shutdown
> > -procrun/14150785#14150785
> >
> > https://issues.apache.org/jira/browse/DAEMON-274
> >
> > I subsequently upgraded Tomcat to 7.0.36 (32-bit, zip) to get the
> updated commons-daemon (http://tomcat.apache.org/tomcat-7.0-
> doc/changelog.html), but to no avail.  I thought perhaps the 32-bit 
> Tomcat/64-bit OS might be a disconnect, so I installed the 64-bit 
> version, but got the same result.  In short, it looks like we're 
> either doing something wrong with our code, or there's a new wrinkle 
> in the OS-service handshaking, or the bug wasn't fixed 
> correctly...maybe in that order.
> >
> > Details below on how our code manifested the problem as well as 
> > other
> steps to reproduce.
> >
> > Our database shutdown code is located in the destroy() function of a
> class implementing org.springframework.beans.factory.DisposableBean.  
> I added a Thread.sleep(5 min) call to reproduce it on my machine.  As 
> long as I shut down the service through the Services panel on Windows, 
> the shutdown sequence fully executes (and takes 5 min, as expected).
> But if I just shut down Windows, the sequence is interrupted.
>
>
>
> 1. From the above I would say that is a Windows feature, that it does 
> not wait for service to shutdown properly.
>
> I'd look into Windows support and MSDN, whether it is a configuration 
> issue or something that be workaround by proper coding.
>

I proposed three options to Steve to change the Windows configuration to either allow more time, or to make Tomcat shutdown dependent on the database shutdown, or both.

> 2. On the "Shutdown" tab of the procrun service configuration dialog
> (Tomcat7w.exe) there is "Timeout" field.
>
> I have "0" (sec) there.

A good option, but it will not necessarily override the Windows default of 12 seconds to shut down a service.

Jeffrey Harris

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

---------------------------------------------------------------------

Sorry, Jeffrey -- and thanks for pointing out your suggestions again -- I only saw your topmost comment last time around establishing a dependency on HSQLDB.  I will check out your other options.

Regards,

Steve
This message is intended only for the named recipient. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action based on the contents of this information is strictly prohibited.


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


RE: Procrun and Tomcat service/OS shutdown on Windows

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> From: Konstantin Kolinko [mailto:knst.kolinko@gmail.com]
> Sent: Thursday, March 14, 2013 4:01 PM
> To: Tomcat Users List
> Subject: Re: Procrun and Tomcat service/OS shutdown on Windows
>
> 2013/3/14 Thomas, Steve <st...@vocollect.com>:
> > Hi -
> >
> > Running Tomcat 7.0.23 or 7.0.37 (32 or 64-bit) installed as a service
> > (either via service.bat or the exe installer) on a Windows 7 64-bit
> > OS, we are seeing an issue where the Windows shutdown kills Tomcat
> > before our webapp shutdown sequence has time to execute fully.
> > (Specifically, we just want to make sure our instance of HSQLDB shuts
> > down correctly, otherwise corruption can ensue.)
> >
> > Details:
> >
> > Initially we were running with 32-bit Tomcat 7.0.23 and saw that our
> > shutdown sequence was not being logged at all when one of our
> > customers shut down his laptop.  It looked like the process was just
> > being killed.  I found a commons-daemon/procrun bug and corresponding
> > fix that seemed like it should address the issue, namely
> >
> > http://stackoverflow.com/questions/13578196/how-to-gracefully-
> shutdown
> > -procrun/14150785#14150785
> >
> > https://issues.apache.org/jira/browse/DAEMON-274
> >
> > I subsequently upgraded Tomcat to 7.0.36 (32-bit, zip) to get the
> updated commons-daemon (http://tomcat.apache.org/tomcat-7.0-
> doc/changelog.html), but to no avail.  I thought perhaps the 32-bit
> Tomcat/64-bit OS might be a disconnect, so I installed the 64-bit
> version, but got the same result.  In short, it looks like we're either
> doing something wrong with our code, or there's a new wrinkle in the
> OS-service handshaking, or the bug wasn't fixed correctly...maybe in
> that order.
> >
> > Details below on how our code manifested the problem as well as other
> steps to reproduce.
> >
> > Our database shutdown code is located in the destroy() function of a
> class implementing org.springframework.beans.factory.DisposableBean.  I
> added a Thread.sleep(5 min) call to reproduce it on my machine.  As
> long as I shut down the service through the Services panel on Windows,
> the shutdown sequence fully executes (and takes 5 min, as expected).
> But if I just shut down Windows, the sequence is interrupted.
>
>
>
> 1. From the above I would say that is a Windows feature, that it does
> not wait for service to shutdown properly.
>
> I'd look into Windows support and MSDN, whether it is a configuration
> issue or something that be workaround by proper coding.
>

I proposed three options to Steve to change the Windows configuration to either allow more time, or
to make Tomcat shutdown dependent on the database shutdown, or both.

> 2. On the "Shutdown" tab of the procrun service configuration dialog
> (Tomcat7w.exe) there is "Timeout" field.
>
> I have "0" (sec) there.

A good option, but it will not necessarily override the Windows default of 12 seconds to shut down a service.

Jeffrey Harris

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


Re: Procrun and Tomcat service/OS shutdown on Windows

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/3/14 Thomas, Steve <st...@vocollect.com>:
> Hi -
>
> Running Tomcat 7.0.23 or 7.0.37 (32 or 64-bit) installed as a service (either via service.bat or the exe installer) on a Windows 7 64-bit OS, we are seeing an issue where the Windows shutdown kills Tomcat before our webapp shutdown sequence has time to execute fully.  (Specifically, we just want to make sure our instance of HSQLDB shuts down correctly, otherwise corruption can ensue.)
>
> Details:
>
> Initially we were running with 32-bit Tomcat 7.0.23 and saw that our shutdown sequence was not being logged at all when one of our customers shut down his laptop.  It looked like the process was just being killed.  I found a commons-daemon/procrun bug and corresponding fix that seemed like it should address the issue, namely
>
> http://stackoverflow.com/questions/13578196/how-to-gracefully-shutdown-procrun/14150785#14150785
>
> https://issues.apache.org/jira/browse/DAEMON-274
>
> I subsequently upgraded Tomcat to 7.0.36 (32-bit, zip) to get the updated commons-daemon (http://tomcat.apache.org/tomcat-7.0-doc/changelog.html), but to no avail.  I thought perhaps the 32-bit Tomcat/64-bit OS might be a disconnect, so I installed the 64-bit version, but got the same result.  In short, it looks like we're either doing something wrong with our code, or there's a new wrinkle in the OS-service handshaking, or the bug wasn't fixed correctly...maybe in that order.
>
> Details below on how our code manifested the problem as well as other steps to reproduce.
>
> Our database shutdown code is located in the destroy() function of a class implementing org.springframework.beans.factory.DisposableBean.  I added a Thread.sleep(5 min) call to reproduce it on my machine.  As long as I shut down the service through the Services panel on Windows, the shutdown sequence fully executes (and takes 5 min, as expected).  But if I just shut down Windows, the sequence is interrupted.



1. From the above I would say that is a Windows feature, that it does
not wait for service to shutdown properly.

I'd look into Windows support and MSDN, whether it is a configuration
issue or something that be workaround by proper coding.

http://support.microsoft.com/kb/146092/en-us

http://msdn.microsoft.com/en-us/library/windows/desktop/dd371756%28v=vs.85%29.aspx

2. On the "Shutdown" tab of the procrun service configuration dialog
(Tomcat7w.exe) there is "Timeout" field.

I have "0" (sec) there.

3. Does your database need 5min to shutdown?

Are you doing something unnecessary (such as compacting it instead of
a simple shutdown)?

Are you using a lot of "memory" tables that HSQL writes out as SQL,
instead of "cached" (on-disk) binary ones?

4. I have several HSQL databases running in-process in Tomcat for my
personal needs. They are configured as <Resource closeMethod="close"
url="...;shutdown=true" /> in server.xml. They shutdown together with
Tomcat (without any additional listeners) and I did not notice any
problems.

5. Is HSQL database corruptible by sudden kill? AFAIK it has own
journal and backup, and there is nothing wrong with aborting it.

The only thing that when it is properly shut down, it looks more
pretty with lesser number of files.


> (As an aside, I don't expect the shutdown to take anywhere near that long in practice, but wanted to make sure the problem manifested itself so that I could address the bug.  We are seeing this with a decent customer test machine, but I can't reproduce it on my machine w/o changes.)
>
> Thinking it might be Spring, I moved the shutdown delay to a ServletContextListener. contextDestroyed() method.  Same effect.
>
> I moved the delay again, and reproduced the same problem in a standalone servlet that overrides HttpServlet.destroy().  I've posted the code at the link below:
>
> http://pastebin.com/yYgrQ2sE
>
> This is the output recorded in the stdout log file for an OS shutdown, and then a shutdown of the service by hand.  We, of course, favor the second. :-)
>
> 2013-03-14 10:05:40 Commons Daemon procrun stdout initialized
> StatusServlet.init()
> Entering StatusServlet.destroy()
> Simulating long shutdown sequence.
>
> 2013-03-14 10:12:29 Commons Daemon procrun stdout initialized
> StatusServlet.init()
> Entering StatusServlet.destroy()
> Simulating long shutdown sequence.
> Simulation complete--sequence finished.
> Exiting StatusServlet.destroy()
>
> Can we guarantee that Windows won't just kill our Tomcat process and potentially corrupt our database?  That's the question.
>
> I'd be grateful for some help on this.  Thanks for your time and attention.
>

Best regards,
Konstantin Kolinko

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


RE: Procrun and Tomcat service/OS shutdown on Windows

Posted by "Thomas, Steve" <st...@vocollect.com>.
Following up...

-----Original Message-----
From: Harris, Jeffrey E. [mailto:Jeffrey.Harris@ManTech.com] 
Sent: Thursday, March 14, 2013 12:52 PM
To: Tomcat Users List
Subject: RE: Procrun and Tomcat service/OS shutdown on Windows

(snip)

Finally you might also want to try delaying the shutdown timer on the system to give Tomcat and/or HSQLDB more time to shutdown.  It might be possible that it is taking longer than the 12 seconds Windows allows by default for a service to shutdown.  That timer can be changed at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control (WaitToKillServiceTimeout value; the data is in milliseconds).  However, Windows 7 and Windows Server 2008 R2 need a hotfix to change this setting (see http://support.microsoft.com/kb/2549760).

Jeffrey Harris
---------------------------------------------------------------------

Jeffrey -

Thanks again for your suggestions.

Our customer is indeed running Win7 professional, so I passed this on.  The SERVICE_ACCEPT_PRESHUTDOWN is interesting for a longer-term fix, if we modified the commons-daemon code ourselves.  

On another note, I corresponded with the HSQLDB maintainer and he told me that if the shutdown is interrupted, the database can be corrupted.  He is plugging various holes in this area, but is not yet taking advantage of any native support for transactional disk writes that might prevent that sort of thing.  Wondering if any of the other embedded db's (Derby or H2) use them...  'More to investigate.

Regards,

Steve
This message is intended only for the named recipient. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action based on the contents of this information is strictly prohibited.


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


RE: Procrun and Tomcat service/OS shutdown on Windows

Posted by "Thomas, Steve" <st...@vocollect.com>.
-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Friday, March 15, 2013 3:37 PM
To: Tomcat Users List
Subject: Re: Procrun and Tomcat service/OS shutdown on Windows

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Steve,

On 3/14/13 1:21 PM, Thomas, Steve wrote:
> Thanks, Jeffrey.  That may be a possibility for the long-term.
> --Steve

Did you read Jeffrey's entire reply? He started by top-posting, but then wrote some much more informative comments at the end of his post.

- -chris
-----------------------------------------------

Chris -

Thanks for calling that out.  That threw me off initially, but following the subsequent comments in the thread, I saw that he had more points to offer and will be checking into them.

Much appreciated,

Steve

This message is intended only for the named recipient. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action based on the contents of this information is strictly prohibited.


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


Re: Procrun and Tomcat service/OS shutdown on Windows

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Steve,

On 3/14/13 1:21 PM, Thomas, Steve wrote:
> Thanks, Jeffrey.  That may be a possibility for the long-term.
> --Steve

Did you read Jeffrey's entire reply? He started by top-posting, but
then wrote some much more informative comments at the end of his post.

- -chris

> 
> -----Original Message----- From: Harris, Jeffrey E.
> [mailto:Jeffrey.Harris@ManTech.com] Sent: Thursday, March 14, 2013
> 12:52 PM To: Tomcat Users List Subject: RE: Procrun and Tomcat
> service/OS shutdown on Windows
> 
> Edit the registry so Tomcat depends on the HSQLDB shutdown.  This
> only works if HSQLDB is also started as a service.
> 
> Jeffrey Harris
> 
>> -----Original Message----- From: Thomas, Steve
>> [mailto:sthomas@vocollect.com] Sent: Thursday, March 14, 2013
>> 12:00 PM To: users@tomcat.apache.org Subject: Procrun and Tomcat
>> service/OS shutdown on Windows
>> 
>> Hi -
>> 
>> Running Tomcat 7.0.23 or 7.0.37 (32 or 64-bit) installed as a
>> service (either via service.bat or the exe installer) on a
>> Windows 7 64-bit OS, we are seeing an issue where the Windows
>> shutdown kills Tomcat before our webapp shutdown sequence has
>> time to execute fully. (Specifically, we just want to make sure
>> our instance of HSQLDB shuts down correctly, otherwise corruption
>> can ensue.)
>> 
>> Details:
>> 
>> Initially we were running with 32-bit Tomcat 7.0.23 and saw that
>> our shutdown sequence was not being logged at all when one of our
>>  customers shut down his laptop.  It looked like the process was
>> just being killed.  I found a commons-daemon/procrun bug and
>> corresponding fix that seemed like it should address the issue,
>> namely
>> 
>> http://stackoverflow.com/questions/13578196/how-to-gracefully-shutdown
>>
>> 
- -
>> procrun/14150785#14150785
>> 
>> https://issues.apache.org/jira/browse/DAEMON-274
>> 
>> I subsequently upgraded Tomcat to 7.0.36 (32-bit, zip) to get the
>>  updated commons-daemon (http://tomcat.apache.org/tomcat-7.0- 
>> doc/changelog.html), but to no avail.  I thought perhaps the
>> 32-bit Tomcat/64-bit OS might be a disconnect, so I installed the
>> 64-bit version, but got the same result.  In short, it looks like
>> we're either doing something wrong with our code, or there's a
>> new wrinkle in the OS-service handshaking, or the bug wasn't
>> fixed correctly...maybe in that order.
>> 
>> Details below on how our code manifested the problem as well as
>> other steps to reproduce.
>> 
>> Our database shutdown code is located in the destroy() function
>> of a class implementing
>> org.springframework.beans.factory.DisposableBean. I added a
>> Thread.sleep(5 min) call to reproduce it on my machine.  As long
>> as I shut down the service through the Services panel on Windows,
>>  the shutdown sequence fully executes (and takes 5 min, as
>> expected). But if I just shut down Windows, the sequence is
>> interrupted.
>> 
>> (As an aside, I don't expect the shutdown to take anywhere near
>> that long in practice, but wanted to make sure the problem
>> manifested itself so that I could address the bug.  We are seeing
>> this with a decent customer test machine, but I can't reproduce
>> it on my machine w/o changes.)
>> 
>> Thinking it might be Spring, I moved the shutdown delay to a 
>> ServletContextListener. contextDestroyed() method.  Same effect.
>> 
>> I moved the delay again, and reproduced the same problem in a 
>> standalone servlet that overrides HttpServlet.destroy().  I've
>> posted the code at the link below:
>> 
>> http://pastebin.com/yYgrQ2sE
>> 
>> This is the output recorded in the stdout log file for an OS
>> shutdown, and then a shutdown of the service by hand.  We, of
>> course, favor the second. :-)
>> 
>> 2013-03-14 10:05:40 Commons Daemon procrun stdout initialized 
>> StatusServlet.init() Entering StatusServlet.destroy() Simulating
>> long shutdown sequence.
>> 
>> 2013-03-14 10:12:29 Commons Daemon procrun stdout initialized 
>> StatusServlet.init() Entering StatusServlet.destroy() Simulating
>> long shutdown sequence. Simulation complete--sequence finished. 
>> Exiting StatusServlet.destroy()
>> 
>> Can we guarantee that Windows won't just kill our Tomcat process
>> and potentially corrupt our database?  That's the question.
>> 
>> I'd be grateful for some help on this.  Thanks for your time and
>>  attention.
>> 
>> Steve T This message is intended only for the named recipient. If
>> you are not the intended recipient, you are notified that
>> disclosing, copying, distributing or taking any action based on
>> the contents of this information is strictly prohibited.
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>>
>> 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> Edit the service entry in the registry (under
> HKEY_Local_Machine\system\currentcontrolset\services\<Tomcat
> Service Name>) so Tomcat depends on HSQLDB.  This only works if
> HSQLDB is also started as a service.  If HSQLDB is started some
> other way (i.e., by the Tomcat web app), you can try and install it
> as a service using the srvany utility (or possibly the sc
> utility).
> 
> If you can configure Tomcat to be dependent on HSQLDB, this will
> also force HSQLDB to start before Tomcat.
> 
> There is a method discussed at
> http://blogs.technet.com/b/askperf/archive/2008/02/04/ws2008-service-shutdown-and-crash-handling.aspx
> that you might try.
> 
> Finally you might also want to try delaying the shutdown timer on
> the system to give Tomcat and/or HSQLDB more time to shutdown.  It
> might be possible that it is taking longer than the 12 seconds
> Windows allows by default for a service to shutdown.  That timer
> can be changed at
> HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control
> (WaitToKillServiceTimeout value; the data is in milliseconds).
> However, Windows 7 and Windows Server 2008 R2 need a hotfix to
> change this setting (see http://support.microsoft.com/kb/2549760).
> 
> Jeffrey Harris
> 
> This e-mail and any attachments are intended only for the use of
> the addressee(s) named herein and may contain proprietary
> information. If you are not the intended recipient of this e-mail
> or believe that you received this email in error, please take
> immediate action to notify the sender of the apparent error by
> reply e-mail; permanently delete the e-mail and any attachments
> from your computer; and do not disseminate, distribute, use, or
> copy this message and any attachments.
> 
> ---------------------------------------------------------------------
>
> 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> This message is intended only for the named recipient. If you are
> not the intended recipient, you are notified that disclosing,
> copying, distributing or taking any action based on the contents of
> this information is strictly prohibited.
> 
> 
> ---------------------------------------------------------------------
>
> 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlFDeEUACgkQ9CaO5/Lv0PAdiQCgrHcAqArzfODuGUykJJbj3YIx
ZE4AoKg8Ooju4DkHE/Wc74c3lh1NKvci
=ArZV
-----END PGP SIGNATURE-----

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


RE: Procrun and Tomcat service/OS shutdown on Windows

Posted by "Thomas, Steve" <st...@vocollect.com>.
Thanks, Jeffrey.  That may be a possibility for the long-term.  --Steve

-----Original Message-----
From: Harris, Jeffrey E. [mailto:Jeffrey.Harris@ManTech.com] 
Sent: Thursday, March 14, 2013 12:52 PM
To: Tomcat Users List
Subject: RE: Procrun and Tomcat service/OS shutdown on Windows

Edit the registry so Tomcat depends on the HSQLDB shutdown.  This only works if HSQLDB is also started as a service.

Jeffrey Harris

> -----Original Message-----
> From: Thomas, Steve [mailto:sthomas@vocollect.com]
> Sent: Thursday, March 14, 2013 12:00 PM
> To: users@tomcat.apache.org
> Subject: Procrun and Tomcat service/OS shutdown on Windows
>
> Hi -
>
> Running Tomcat 7.0.23 or 7.0.37 (32 or 64-bit) installed as a service 
> (either via service.bat or the exe installer) on a Windows 7 64-bit 
> OS, we are seeing an issue where the Windows shutdown kills Tomcat 
> before our webapp shutdown sequence has time to execute fully.  
> (Specifically, we just want to make sure our instance of HSQLDB shuts 
> down correctly, otherwise corruption can ensue.)
>
> Details:
>
> Initially we were running with 32-bit Tomcat 7.0.23 and saw that our 
> shutdown sequence was not being logged at all when one of our 
> customers shut down his laptop.  It looked like the process was just 
> being killed.  I found a commons-daemon/procrun bug and corresponding 
> fix that seemed like it should address the issue, namely
>
> http://stackoverflow.com/questions/13578196/how-to-gracefully-shutdown
> -
> procrun/14150785#14150785
>
> https://issues.apache.org/jira/browse/DAEMON-274
>
> I subsequently upgraded Tomcat to 7.0.36 (32-bit, zip) to get the 
> updated commons-daemon (http://tomcat.apache.org/tomcat-7.0-
> doc/changelog.html), but to no avail.  I thought perhaps the 32-bit 
> Tomcat/64-bit OS might be a disconnect, so I installed the 64-bit 
> version, but got the same result.  In short, it looks like we're 
> either doing something wrong with our code, or there's a new wrinkle 
> in the OS-service handshaking, or the bug wasn't fixed 
> correctly...maybe in that order.
>
> Details below on how our code manifested the problem as well as other 
> steps to reproduce.
>
> Our database shutdown code is located in the destroy() function of a 
> class implementing org.springframework.beans.factory.DisposableBean.  
> I added a Thread.sleep(5 min) call to reproduce it on my machine.  As 
> long as I shut down the service through the Services panel on Windows, 
> the shutdown sequence fully executes (and takes 5 min, as expected).
> But if I just shut down Windows, the sequence is interrupted.
>
> (As an aside, I don't expect the shutdown to take anywhere near that 
> long in practice, but wanted to make sure the problem manifested 
> itself so that I could address the bug.  We are seeing this with a 
> decent customer test machine, but I can't reproduce it on my machine 
> w/o
> changes.)
>
> Thinking it might be Spring, I moved the shutdown delay to a 
> ServletContextListener. contextDestroyed() method.  Same effect.
>
> I moved the delay again, and reproduced the same problem in a 
> standalone servlet that overrides HttpServlet.destroy().  I've posted 
> the code at the link below:
>
> http://pastebin.com/yYgrQ2sE
>
> This is the output recorded in the stdout log file for an OS shutdown, 
> and then a shutdown of the service by hand.  We, of course, favor the 
> second. :-)
>
> 2013-03-14 10:05:40 Commons Daemon procrun stdout initialized
> StatusServlet.init()
> Entering StatusServlet.destroy()
> Simulating long shutdown sequence.
>
> 2013-03-14 10:12:29 Commons Daemon procrun stdout initialized
> StatusServlet.init()
> Entering StatusServlet.destroy()
> Simulating long shutdown sequence.
> Simulation complete--sequence finished.
> Exiting StatusServlet.destroy()
>
> Can we guarantee that Windows won't just kill our Tomcat process and 
> potentially corrupt our database?  That's the question.
>
> I'd be grateful for some help on this.  Thanks for your time and 
> attention.
>
> Steve T
> This message is intended only for the named recipient. If you are not 
> the intended recipient, you are notified that disclosing, copying, 
> distributing or taking any action based on the contents of this 
> information is strictly prohibited.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

Edit the service entry in the registry (under HKEY_Local_Machine\system\currentcontrolset\services\<Tomcat Service Name>) so Tomcat depends on HSQLDB.  This only works if HSQLDB is also started as a service.  If HSQLDB is started some other way (i.e., by the Tomcat web app), you can try and install it as a service using the srvany utility (or possibly the sc utility).

If you can configure Tomcat to be dependent on HSQLDB, this will also force HSQLDB to start before Tomcat.

There is a method discussed at http://blogs.technet.com/b/askperf/archive/2008/02/04/ws2008-service-shutdown-and-crash-handling.aspx that you might try.

Finally you might also want to try delaying the shutdown timer on the system to give Tomcat and/or HSQLDB more time to shutdown.  It might be possible that it is taking longer than the 12 seconds Windows allows by default for a service to shutdown.  That timer can be changed at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control (WaitToKillServiceTimeout value; the data is in milliseconds).  However, Windows 7 and Windows Server 2008 R2 need a hotfix to change this setting (see http://support.microsoft.com/kb/2549760).

Jeffrey Harris

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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

This message is intended only for the named recipient. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action based on the contents of this information is strictly prohibited.


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


Re: Procrun and Tomcat service/OS shutdown on Windows

Posted by André Warnier <aw...@ice-sa.com>.
Harris, Jeffrey E. wrote:
> 
>> -----Original Message-----
>> From: Jeffrey Janner [mailto:Jeffrey.Janner@PolyDyne.com]
>> Sent: Monday, March 18, 2013 12:27 PM
>> To: 'Tomcat Users List'
>> Subject: RE: Procrun and Tomcat service/OS shutdown on Windows
>>
>>> -----Original Message-----
>>> From: Harris, Jeffrey E. [mailto:Jeffrey.Harris@ManTech.com]
>>> Sent: Thursday, March 14, 2013 11:52 AM
>>> To: Tomcat Users List
>>> Subject: RE: Procrun and Tomcat service/OS shutdown on Windows
>>>
>>> Edit the registry so Tomcat depends on the HSQLDB shutdown.  This
>> only
>>> works if HSQLDB is also started as a service.
>>>
>>> Edit the service entry in the registry (under
>>> HKEY_Local_Machine\system\currentcontrolset\services\<Tomcat Service
>>> Name>) so Tomcat depends on HSQLDB.  This only works if HSQLDB is
>> also
>>> started as a service.  If HSQLDB is started some other way (i.e., by
>>> the Tomcat web app), you can try and install it as a service using
>> the
>>> srvany utility (or possibly the sc utility).
>>>
>>> If you can configure Tomcat to be dependent on HSQLDB, this will also
>>> force HSQLDB to start before Tomcat.
>>>
>> I just wanted to post a word of warning on depending on this last
>> "feature".
>> While Windows will start the HSQLDB server before the Tomcat server, it
>> doesn't necessarily imply that the DB will be ready for service.  As
>> soon as the HSQLDB service reports "started", Windows will start the
>> next service that's dependant on it.  You will want to verify the
>> behavior of your database before relying on this feature.
>> Spoken as one bitten by trying to do this with Oracle some years back.
>> The Oracle DB will report started looong before the recovery process is
>> complete and the DB is open for connections.
>> Jeff
>>
> 
> Good point!
> 

An additional note maybe :
This may or may not be applicable to Tomcat running as a Service through procrun, but 
having written programs in Perl which act as Windows Services, I know that the "service 
program" itself can indicate to Windows how long it will take to start it as a service or 
stop it as a service.  This then conditions Windows (probably the "Windows Service 
Manager") to wait that long, before it declares the Service as non-responsive (and, in the 
case of a "stop service" signal, starts taking more drastic action).
For example, this impacts the "progress bar" which you see during a "start service" or 
"stop service" action in the GUI interaction with Services.  If the Service tells Windows 
that it needs one full minute to start, then that progress bar will take a minute to reach 
100%.
I do not know if procrun currently allows the setting of this kind of parameter.  But if 
it doesn't, and if this would help you, you could always file an enhancement request.

Note that I do use this in the programs mentioned above, without really understanding how 
it works deep down.  It is all a bit weird, because it doesn't seem to be 100% 
deterministic, and involves a Windows "Event loop" with "messages" between the program and 
the Service Manager.  But in my case it does work for where I wanted it to work, and I 
never dug deeper.



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


RE: Procrun and Tomcat service/OS shutdown on Windows

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> From: Jeffrey Janner [mailto:Jeffrey.Janner@PolyDyne.com]
> Sent: Monday, March 18, 2013 12:27 PM
> To: 'Tomcat Users List'
> Subject: RE: Procrun and Tomcat service/OS shutdown on Windows
>
> > -----Original Message-----
> > From: Harris, Jeffrey E. [mailto:Jeffrey.Harris@ManTech.com]
> > Sent: Thursday, March 14, 2013 11:52 AM
> > To: Tomcat Users List
> > Subject: RE: Procrun and Tomcat service/OS shutdown on Windows
> >
> > Edit the registry so Tomcat depends on the HSQLDB shutdown.  This
> only
> > works if HSQLDB is also started as a service.
> >
> > Edit the service entry in the registry (under
> > HKEY_Local_Machine\system\currentcontrolset\services\<Tomcat Service
> > Name>) so Tomcat depends on HSQLDB.  This only works if HSQLDB is
> also
> > started as a service.  If HSQLDB is started some other way (i.e., by
> > the Tomcat web app), you can try and install it as a service using
> the
> > srvany utility (or possibly the sc utility).
> >
> > If you can configure Tomcat to be dependent on HSQLDB, this will also
> > force HSQLDB to start before Tomcat.
> >
>
> I just wanted to post a word of warning on depending on this last
> "feature".
> While Windows will start the HSQLDB server before the Tomcat server, it
> doesn't necessarily imply that the DB will be ready for service.  As
> soon as the HSQLDB service reports "started", Windows will start the
> next service that's dependant on it.  You will want to verify the
> behavior of your database before relying on this feature.
> Spoken as one bitten by trying to do this with Oracle some years back.
> The Oracle DB will report started looong before the recovery process is
> complete and the DB is open for connections.
> Jeff
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

Good point!

Jeffrey Harris
Jeffrey Harris

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


RE: Procrun and Tomcat service/OS shutdown on Windows

Posted by Jeffrey Janner <Je...@PolyDyne.com>.
> -----Original Message-----
> From: Harris, Jeffrey E. [mailto:Jeffrey.Harris@ManTech.com]
> Sent: Thursday, March 14, 2013 11:52 AM
> To: Tomcat Users List
> Subject: RE: Procrun and Tomcat service/OS shutdown on Windows
> 
> Edit the registry so Tomcat depends on the HSQLDB shutdown.  This only
> works if HSQLDB is also started as a service.
> 
> Edit the service entry in the registry (under
> HKEY_Local_Machine\system\currentcontrolset\services\<Tomcat Service
> Name>) so Tomcat depends on HSQLDB.  This only works if HSQLDB is also
> started as a service.  If HSQLDB is started some other way (i.e., by
> the Tomcat web app), you can try and install it as a service using the
> srvany utility (or possibly the sc utility).
> 
> If you can configure Tomcat to be dependent on HSQLDB, this will also
> force HSQLDB to start before Tomcat.
> 

I just wanted to post a word of warning on depending on this last "feature".
While Windows will start the HSQLDB server before the Tomcat server, it doesn't necessarily imply that the DB will be ready for service.  As soon as the HSQLDB service reports "started", Windows will start the next service that's dependant on it.  You will want to verify the behavior of your database before relying on this feature.
Spoken as one bitten by trying to do this with Oracle some years back.  The Oracle DB will report started looong before the recovery process is complete and the DB is open for connections.
Jeff


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


RE: Procrun and Tomcat service/OS shutdown on Windows

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.
Edit the registry so Tomcat depends on the HSQLDB shutdown.  This only works if HSQLDB is also started as a service.

Jeffrey Harris

> -----Original Message-----
> From: Thomas, Steve [mailto:sthomas@vocollect.com]
> Sent: Thursday, March 14, 2013 12:00 PM
> To: users@tomcat.apache.org
> Subject: Procrun and Tomcat service/OS shutdown on Windows
>
> Hi -
>
> Running Tomcat 7.0.23 or 7.0.37 (32 or 64-bit) installed as a service
> (either via service.bat or the exe installer) on a Windows 7 64-bit OS,
> we are seeing an issue where the Windows shutdown kills Tomcat before
> our webapp shutdown sequence has time to execute fully.  (Specifically,
> we just want to make sure our instance of HSQLDB shuts down correctly,
> otherwise corruption can ensue.)
>
> Details:
>
> Initially we were running with 32-bit Tomcat 7.0.23 and saw that our
> shutdown sequence was not being logged at all when one of our customers
> shut down his laptop.  It looked like the process was just being
> killed.  I found a commons-daemon/procrun bug and corresponding fix
> that seemed like it should address the issue, namely
>
> http://stackoverflow.com/questions/13578196/how-to-gracefully-shutdown-
> procrun/14150785#14150785
>
> https://issues.apache.org/jira/browse/DAEMON-274
>
> I subsequently upgraded Tomcat to 7.0.36 (32-bit, zip) to get the
> updated commons-daemon (http://tomcat.apache.org/tomcat-7.0-
> doc/changelog.html), but to no avail.  I thought perhaps the 32-bit
> Tomcat/64-bit OS might be a disconnect, so I installed the 64-bit
> version, but got the same result.  In short, it looks like we're either
> doing something wrong with our code, or there's a new wrinkle in the
> OS-service handshaking, or the bug wasn't fixed correctly...maybe in
> that order.
>
> Details below on how our code manifested the problem as well as other
> steps to reproduce.
>
> Our database shutdown code is located in the destroy() function of a
> class implementing org.springframework.beans.factory.DisposableBean.  I
> added a Thread.sleep(5 min) call to reproduce it on my machine.  As
> long as I shut down the service through the Services panel on Windows,
> the shutdown sequence fully executes (and takes 5 min, as expected).
> But if I just shut down Windows, the sequence is interrupted.
>
> (As an aside, I don't expect the shutdown to take anywhere near that
> long in practice, but wanted to make sure the problem manifested itself
> so that I could address the bug.  We are seeing this with a decent
> customer test machine, but I can't reproduce it on my machine w/o
> changes.)
>
> Thinking it might be Spring, I moved the shutdown delay to a
> ServletContextListener. contextDestroyed() method.  Same effect.
>
> I moved the delay again, and reproduced the same problem in a
> standalone servlet that overrides HttpServlet.destroy().  I've posted
> the code at the link below:
>
> http://pastebin.com/yYgrQ2sE
>
> This is the output recorded in the stdout log file for an OS shutdown,
> and then a shutdown of the service by hand.  We, of course, favor the
> second. :-)
>
> 2013-03-14 10:05:40 Commons Daemon procrun stdout initialized
> StatusServlet.init()
> Entering StatusServlet.destroy()
> Simulating long shutdown sequence.
>
> 2013-03-14 10:12:29 Commons Daemon procrun stdout initialized
> StatusServlet.init()
> Entering StatusServlet.destroy()
> Simulating long shutdown sequence.
> Simulation complete--sequence finished.
> Exiting StatusServlet.destroy()
>
> Can we guarantee that Windows won't just kill our Tomcat process and
> potentially corrupt our database?  That's the question.
>
> I'd be grateful for some help on this.  Thanks for your time and
> attention.
>
> Steve T
> This message is intended only for the named recipient. If you are not
> the intended recipient, you are notified that disclosing, copying,
> distributing or taking any action based on the contents of this
> information is strictly prohibited.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

Edit the service entry in the registry (under HKEY_Local_Machine\system\currentcontrolset\services\<Tomcat Service Name>) so Tomcat depends on HSQLDB.  This only works if HSQLDB is also started as a service.  If HSQLDB is started some other way (i.e., by the Tomcat web app), you can try and install it as a service using the srvany utility (or possibly the sc utility).

If you can configure Tomcat to be dependent on HSQLDB, this will also force HSQLDB to start before Tomcat.

There is a method discussed at http://blogs.technet.com/b/askperf/archive/2008/02/04/ws2008-service-shutdown-and-crash-handling.aspx that you might try.

Finally you might also want to try delaying the shutdown timer on the system to give Tomcat and/or HSQLDB more time to shutdown.  It might be possible that it is taking longer than the 12 seconds Windows allows by default for a service to shutdown.  That timer can be changed at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control (WaitToKillServiceTimeout value; the data is in milliseconds).  However, Windows 7 and Windows Server 2008 R2 need a hotfix to change this setting (see http://support.microsoft.com/kb/2549760).

Jeffrey Harris

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


RE: Procrun and Tomcat service/OS shutdown on Windows

Posted by "Thomas, Steve" <st...@vocollect.com>.
-----Original Message-----
From: Howard W. Smith, Jr. [mailto:smithh032772@gmail.com] 
Sent: Friday, March 15, 2013 12:11 AM
To: Tomcat Users List
Subject: Re: Procrun and Tomcat service/OS shutdown on Windows

On Thu, Mar 14, 2013 at 12:00 PM, Thomas, Steve <st...@vocollect.com>wrote:

>
> Running Tomcat 7.0.23 or 7.0.37 (32 or 64-bit) installed as a service 
> (either via service.bat or the exe installer) on a Windows 7 64-bit 
> OS, we are seeing an issue where the Windows shutdown kills Tomcat 
> before our webapp shutdown sequence has time to execute fully.


(Specifically, we just want to make sure our instance of HSQLDB shuts down
> correctly, otherwise corruption can ensue.)
>
>
Few months ago, my web app was running on Windows Server 2003 R2, 32-bit Client JVM and Tomcat versions 7.0.34 and 7.0.35. Within the last 3 months, my web app has been running on Windows Server 2008 R2, 64-bit Server JVM, and Tomcat version 7.0.35 and 7.0.37 (since I am running TomEE 1.5.2+).

anyway, Windows shutdown and restarted itself because of Windows Updates (automatic updates) and i have experienced at least 1 power outage due to storm(s), and my Apache Derby (embedded) has not corrupted yet, at all.
----------------------------------------------------

My manager has had our app and HSQLDB running for a while on his laptop and hasn't seen an issue, either.  Our customer had several shutdowns where everything was fine (even though the shutdown sequence wasn't even started) and then had a couple where we had gotten so far as to issue the SHUTDOWN command to HSQLDB and then the database came back corrupt on the next startup. 

Thanks for your input...still reviewing the posts today.

Regards,

Steve




This message is intended only for the named recipient. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action based on the contents of this information is strictly prohibited.


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


Re: Procrun and Tomcat service/OS shutdown on Windows

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Thu, Mar 14, 2013 at 12:00 PM, Thomas, Steve <st...@vocollect.com>wrote:

>
> Running Tomcat 7.0.23 or 7.0.37 (32 or 64-bit) installed as a service
> (either via service.bat or the exe installer) on a Windows 7 64-bit OS, we
> are seeing an issue where the Windows shutdown kills Tomcat before our
> webapp shutdown sequence has time to execute fully.


(Specifically, we just want to make sure our instance of HSQLDB shuts down
> correctly, otherwise corruption can ensue.)
>
>
Few months ago, my web app was running on Windows Server 2003 R2, 32-bit
Client JVM and Tomcat versions 7.0.34 and 7.0.35. Within the last 3 months,
my web app has been running on Windows Server 2008 R2, 64-bit Server JVM,
and Tomcat version 7.0.35 and 7.0.37 (since I am running TomEE 1.5.2+).

anyway, Windows shutdown and restarted itself because of Windows Updates
(automatic updates) and i have experienced at least 1 power outage due to
storm(s), and my Apache Derby (embedded) has not corrupted yet, at all.


> Can we guarantee that Windows won't just kill our Tomcat process and
> potentially corrupt our database?  That's the question.
>
>
Per my experience, when Windows shut down, it seems as though Windows
clicks the Stop button on the tomcat7w.exe window. It 'stops' or 'shuts
down' Tomcat....'normally'. And also, as I stated earlier, it does not
leave my database corrupted.

Now, prior to using TomEE/Tomcat, I used Glassfish 3.1+, and I came across
some shutdown hook code, and wanted to use it to 'shut down my database
normally'. Do I really need it? Honestly, I don't think so, but i get no
exceptions when shutting down the Apache Derby database, so I'll leave it
in my CDI @ApplicationScoped @PreDestroy method.

So, below is my log when Tomcat shut down normally, because Windows shut
down due to Windows Update (automatic) the other night. See below. The last
line below is when server restarted and TomEE/tomcat7 restarted, since
tomcat7 service starts...automatically.

Mar 13, 2013 1:42:24 AM jsf.users.pf_UsersController logout
INFO: pf_UsersController.logout(): administrator logged out at Wed Mar 13
01:42:24 EDT 2013
Mar 13, 2013 2:42:59 AM org.apache.openejb.cdi.CdiAppContextsService
lazyStartSessionContext
WARNING: Could NOT lazily initialize session context because of null
RequestContext
Mar 13, 2013 2:42:59 AM org.apache.openejb.cdi.CdiAppContextsService
lazyStartSessionContext
WARNING: Could NOT lazily initialize session context because of null
RequestContext
Mar 13, 2013 3:03:30 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-nio-8080"]
Mar 13, 2013 3:03:31 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Mar 13, 2013 3:03:31 AM org.apache.catalina.core.StandardService
stopInternal
INFO: Stopping service Catalina
Mar 13, 2013 3:03:31 AM org.apache.openejb.assembler.classic.Assembler
destroyApplication
INFO: Undeploying app: D:\apache-tomee-plus-1.6.0-SNAPSHOT\webapps\mcmsweb
Mar 13, 2013 3:03:31 AM pf.ApplicationScopeBean destroy
INFO: ApplicationScopeBean.destroy() invoked
Mar 13, 2013 3:03:31 AM utils.database.DerbyUtil shutdown
INFO: DerbyUtil.java: shutdown() invoked
Mar 13, 2013 3:03:31 AM utils.database.DerbyUtil loadDriver
INFO: DerbyUtil.java: loadDriver(): Loaded driver
(org.apache.derby.jdbc.EmbeddedDriver) successfully
Mar 13, 2013 3:03:31 AM utils.database.DerbyUtil shutdown
INFO: DerbyUtil.java: shutdown(): Derby shut down normally
Mar 13, 2013 3:03:31 AM pf.ApplicationScopeBean destroy
INFO: ApplicationScopeBean.destroy(): gCalUtil.shutdown() completed
Mar 13, 2013 3:03:31 AM pf.ApplicationScopeBean destroy
INFO: ApplicationScopeBean.destroy(): jodConverter.shutdown() completed
Mar 13, 2013 3:03:31 AM mdb.ApplicationMessageBean shutdown
INFO: ApplicationMessageBean.shutdown() BEGIN
Mar 13, 2013 3:03:31 AM mdb.ApplicationMessageBean shutdown
INFO: ApplicationMessageBean.shutdown() END
Mar 13, 2013 3:03:31 AM pf.ApplicationScopeBean destroy
INFO: ApplicationScopeBean.destroy(): applicationMessageBean.shutdown()
completed
Mar 13, 2013 3:03:31 AM org.apache.activemq.ra.ActiveMQEndpointWorker stop
INFO: Stopping
Mar 13, 2013 3:03:31 AM org.apache.activemq.ra.ActiveMQEndpointWorker stop
INFO: Stopping
Mar 13, 2013 3:03:32 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/mcmsweb] appears to have started a thread
named [PoolIdleReleaseTimer] but has failed to stop it. This is very likely
to create a memory leak.
Mar 13, 2013 3:03:32 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/mcmsweb] appears to have started a thread
named [Default JMS Resource Adapter-worker-1] but has failed to stop it.
This is very likely to create a memory leak.
Mar 13, 2013 3:03:32 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/mcmsweb] appears to have started a thread
named [Default JMS Resource Adapter-worker-2] but has failed to stop it.
This is very likely to create a memory leak.
Mar 13, 2013 3:03:32 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/mcmsweb] appears to have started a thread
named [ActiveMQ VMTransport: vm://localhost#5-2] but has failed to stop it.
This is very likely to create a memory leak.
Mar 13, 2013 3:03:32 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/mcmsweb] appears to have started a thread
named [ActiveMQ VMTransport: vm://localhost#5-3] but has failed to stop it.
This is very likely to create a memory leak.
Mar 13, 2013 3:03:32 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/mcmsweb] appears to have started a thread
named [ActiveMQ VMTransport: vm://localhost#4-2] but has failed to stop it.
This is very likely to create a memory leak.
Mar 13, 2013 3:03:32 AM org.apache.catalina.loader.WebappClassLoader
checkThreadLocalMapForLeaks
SEVERE: The web application [/mcmsweb] created a ThreadLocal with key of
type [com.google.gson.Gson$1] (value [com.google.gson.Gson$1@75e3139d]) and
a value of type [java.util.HashMap] (value [{}]) but failed to remove it
when the web application was stopped. Threads are going to be renewed over
time to try and avoid a probable memory leak.
Mar 13, 2013 3:03:32 AM org.apache.catalina.loader.WebappClassLoader
checkThreadLocalMapForLeaks
SEVERE: The web application [/mcmsweb] created a ThreadLocal with key of
type [com.google.api.client.util.escape.Platform$1] (value
[com.google.api.client.util.escape.Platform$1@f1ce4e2]) and a value of type
[char[]] (value [[C@31f6b92e]) but failed to remove it when the web
application was stopped. Threads are going to be renewed over time to try
and avoid a probable memory leak.
Mar 13, 2013 3:03:33 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-nio-8080"]
Mar 13, 2013 3:03:33 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Mar 13, 2013 3:03:33 AM org.apache.openejb.server.SimpleServiceManager stop
INFO: Stopping server services
Mar 13, 2013 3:03:33 AM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler OpenEJB-TimerService-Scheduler_$_OpenEJB shutting down.
Mar 13, 2013 3:03:33 AM org.quartz.core.QuartzScheduler standby
INFO: Scheduler OpenEJB-TimerService-Scheduler_$_OpenEJB paused.
Mar 13, 2013 3:03:33 AM org.quartz.core.QuartzScheduler unregisterJMX
INFO: Scheduler unregistered from name
'quartz:type=QuartzScheduler,name=OpenEJB-TimerService-Scheduler,instance=OpenEJB'
in the local MBeanServer.
Mar 13, 2013 3:03:33 AM org.apache.openejb.assembler.classic.Assembler
destroyApplication
INFO: Undeploying app: openejb
Mar 13, 2013 3:03:33 AM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler OpenEJB-TimerService-Scheduler_$_OpenEJB shutdown complete.
Mar 13, 2013 3:03:33 AM org.apache.openejb.assembler.classic.Assembler
destroyResource
INFO: Stopping ResourceAdapter: Default JMS Resource Adapter
Mar 13, 2013 3:03:33 AM
org.apache.openejb.resource.activemq.ActiveMQResourceAdapter stop
INFO: Stopping ActiveMQ
Mar 13, 2013 3:03:35 AM
org.apache.openejb.resource.activemq.ActiveMQResourceAdapter stopImpl
INFO: Stopped ActiveMQ broker
Mar 13, 2013 3:03:35 AM org.apache.openejb.assembler.classic.Assembler
destroyResource
INFO: Closing DataSource: Default Unmanaged JDBC Database

2013-03-13 03:06:01 Commons Daemon procrun stderr initialized

RE: Procrun and Tomcat service/OS shutdown on Windows

Posted by "Thomas, Steve" <st...@vocollect.com>.
Unfortunately, that appears to be the case with HSQLDB.  We maintain a set of nightly backups to address cases like those you've cited; however, if we can avoid issues arising from just shutting down the OS, that would help.

Regards,

Steve

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Thursday, March 14, 2013 1:00 PM
To: Tomcat Users List
Subject: RE: Procrun and Tomcat service/OS shutdown on Windows

> From: Thomas, Steve [mailto:sthomas@vocollect.com]
> Subject: Procrun and Tomcat service/OS shutdown on Windows

> Can we guarantee that Windows won't just kill our Tomcat process and 
> potentially corrupt our database?

If the integrity of your database depends on an orderly shutdown sequence, you need a better database.  What happens if there's a power outage?  What about some other abrupt hardware or software failure?

 - 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

This message is intended only for the named recipient. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action based on the contents of this information is strictly prohibited.


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


RE: Procrun and Tomcat service/OS shutdown on Windows

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Thomas, Steve [mailto:sthomas@vocollect.com] 
> Subject: Procrun and Tomcat service/OS shutdown on Windows

> Can we guarantee that Windows won't just kill our Tomcat process and potentially 
> corrupt our database?

If the integrity of your database depends on an orderly shutdown sequence, you need a better database.  What happens if there's a power outage?  What about some other abrupt hardware or software failure?

 - 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org