On Thu, Mar 14, 2013 at 12:00 PM, Thomas, Steve <stho...@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