Discussion:
Shutdown TomEE hangs at @PreDestroy of CDI @ApplicationScoped bean
Howard W. Smith, Jr.
2012-12-20 05:54:47 UTC
Permalink
Is this a known issue of TomEE 1.5.1 on Win32 (Windows Server 2003 32-bit)?
I am experiencing this issue, and I usually have use Windows Task Manager
to end the process. I have SLF4J 'info' lines in the @PreDestroy method. I
usually see those lines outputted to server log when TomEE was started
minutes ago. I usually see this behavior when running TomEE all day without
a shutdown or restart. Windows Task Manager seems to reveal a memory leak;
the server/catalina log usually mentions possible threadlocal memory leaks,
especially related to the use of Google Calendar API.

I am currently running the following:

apache-tomee-1.5.1-20121207.152523-plus.zip

tomee-catalina-1.5.1-20121212.041530-107.jar (issue is duplicated with
'and' without this JAR)

I think this all started to occur, when I added javamail imap close folder
and close store. My server/catalina log also reveals that my current
implementation, @Schedule every 10 minutes to check imap store/folder, does
result in imap exceptions (unknown host, etc...).

If this issue is possibly resolved in a later release of TomEE, then please
let me know.

Thanks,
Howard
Howard W. Smith, Jr.
2012-12-20 10:55:00 UTC
Permalink
Okay, I commented out the javamail imap close folder and close store in
@PreDestroy method, started TomEE/webapp, completed an imap
action/transaction (download data from email server and import into
database), and then shutdown TomEE/webapp, and TomEE/webapp shutdown,
normally-and-successfully. That only took a few minutes, and I reported,
that TomEE usually shuts down, normally, when TomEE is running for few
minutes; will have to see if TomEE shuts down
normally/effortlessly/successfully later on today (hours later).

below is the log


Dec 20, 2012 5:47:20 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-apr-8080"]
Dec 20, 2012 5:47:20 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-apr-8009"]
Dec 20, 2012 5:47:20 AM org.apache.catalina.core.StandardService
stopInternal
INFO: Stopping service Catalina
Dec 20, 2012 5:47:20 AM org.apache.openejb.assembler.classic.Assembler
destroyApplication
INFO: Undeploying app: D:\apache-tomee-plus-1.5.1\webapps\docs
Dec 20, 2012 5:47:21 AM org.apache.openejb.assembler.classic.Assembler
destroyApplication
INFO: Undeploying app: D:\apache-tomee-plus-1.5.1\webapps\mcmsweb
Dec 20, 2012 5:47:21 AM pf.ApplicationScopeBean log
INFO: ApplicationScopeBean.destroy() invoked
Dec 20, 2012 5:47:21 AM utils.database.DerbyUtil shutdown
INFO: DerbyUtil.java: shutdown() invoked
Dec 20, 2012 5:47:21 AM utils.database.DerbyUtil loadDriver
INFO: DerbyUtil.java: loadDriver(): Loaded driver
(org.apache.derby.jdbc.EmbeddedDriver) successfully
Dec 20, 2012 5:47:23 AM utils.database.DerbyUtil shutdown
INFO: DerbyUtil.java: shutdown(): Derby shut down normally
Dec 20, 2012 5:47:23 AM pf.ApplicationScopeBean log
INFO: ApplicationScopeBean.destroy(): gCalUtil.shutdown() completed
Dec 20, 2012 5:47:23 AM pf.ApplicationScopeBean log
INFO: ApplicationScopeBean.destroy(): jodConverter.shutdown() completed
Dec 20, 2012 5:47:24 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$***@160c6d3]) 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.
Dec 20, 2012 5:47:24 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$***@9d799d]) and a value of type
[char[]] (value [[***@9b670c]) 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.
Dec 20, 2012 5:47:37 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-apr-8080"]
Dec 20, 2012 5:47:37 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-apr-8009"]
Dec 20, 2012 5:47:37 AM org.apache.openejb.server.SimpleServiceManager stop
INFO: Stopping server services
Dec 20, 2012 5:47:37 AM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler OpenEJB-TimerService-Scheduler_$_OpenEJB shutting down.
Dec 20, 2012 5:47:37 AM org.quartz.core.QuartzScheduler standby
INFO: Scheduler OpenEJB-TimerService-Scheduler_$_OpenEJB paused.
Dec 20, 2012 5:47:37 AM org.quartz.core.QuartzScheduler unregisterJMX
INFO: Scheduler unregistered from name
'quartz:type=QuartzScheduler,name=OpenEJB-TimerService-Scheduler,instance=OpenEJB'
in the local MBeanServer.
Dec 20, 2012 5:47:37 AM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler OpenEJB-TimerService-Scheduler_$_OpenEJB shutdown complete.
Dec 20, 2012 5:47:37 AM org.apache.openejb.assembler.classic.Assembler
destroyApplication
INFO: Undeploying app: openejb
Please use CMSClassUnloadingEnabled in place of CMSPermGenSweepingEnabled
in the future


On Thu, Dec 20, 2012 at 12:54 AM, Howard W. Smith, Jr. <
Post by Howard W. Smith, Jr.
I think this all started to occur, when I added javamail imap close folder
and close store. My server/catalina log also reveals that my current
result in imap exceptions (unknown host, etc...).
AndyG
2012-12-20 12:09:07 UTC
Permalink
Wrap your preDestroy method body in a thread and 'join' it for a period
before giving up on it. If anything 'hangs' in preDestroy then it will
prevent a shutdown.

Also noted from that log output, you should replace the JVM flag
CMSPermGenSweepingEnabled with CMSClassUnloadingEnabled (which also requires
UseConcMarkSweepGC). Google is your friend.

Andy.



--
View this message in context: http://openejb.979440.n4.nabble.com/Shutdown-TomEE-hangs-at-PreDestroy-of-CDI-ApplicationScoped-bean-tp4659842p4659855.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Howard W. Smith, Jr.
2012-12-21 04:20:36 UTC
Permalink
AndyG,
Post by AndyG
Wrap your preDestroy method body in a thread and 'join' it for a period
before giving up on it. If anything 'hangs' in preDestroy then it will
prevent a shutdown.
As I stated earlier, I would shutdown the server later on today, and
confirm if the commented out code would allow TomEE to shutdown. I let
TomEE run all day and finally shutdown TomEE, and TomEE shutdown
normally/successfully without the need to use Windows Task Manager. :)

I need to research imap close folder and store, and find out if this is a
good practice, on shutdown of the container/webapp.
Post by AndyG
Also noted from that log output, you should replace the JVM flag
CMSPermGenSweepingEnabled with CMSClassUnloadingEnabled (which also requires
UseConcMarkSweepGC). Google is your friend.
I used my friend, Google, to find out how to prevent the warning/msg above.
I tried to change my settings as recommended on the following URL:

http://docs.oracle.com/cd/E13209_01/wlcp/wlss30/configwlss/jvmgc.html

When trying to alter my JVM options, TomEE would not start. Below is what
showed up in stderr log every time i altered JVM options and attempted to
start TomEE. So, I reverted to the JVM options that I've been using, and I
was able to start TomEE. :)


2012-12-20 22:43:54 Commons Daemon procrun stderr initialized

2012-12-20 22:49:05 Commons Daemon procrun stderr initialized

2012-12-20 22:49:54 Commons Daemon procrun stderr initialized

2012-12-20 22:50:28 Commons Daemon procrun stderr initialized

2012-12-20 22:52:31 Commons Daemon procrun stderr initialized

2012-12-20 22:53:21 Commons Daemon procrun stderr initialized

2012-12-20 22:55:16 Commons Daemon procrun stderr initialized

Loading...