On Jan 3, 11:42 am, √iktor Klang <
viktor.kl...@gmail.com> wrote:
> Yes, but you can probably just extend the default one.
>
I tried registering this:
public class AkkaShutdownListener implements ServletContextListener {
Logger log = LoggerFactory.getLogger(AkkaShutdownListener.class);
@Override
public void contextInitialized(ServletContextEvent sce) {
log.info("Akka shutdown listener got init event");
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
log.info("Akka shutdown listener got destroy event, shutting
down Akka ...");
ActorRegistry.shutdownAll();
}
}
That does get called and I get some messages about it:
[INFO] [2011-01-03 11:47:42,140] [http-8080-exec-5]
akka.actor.ActorRegistry$: Shutting down all actors in the system...
[DEBUG] [2011-01-03 11:47:42,153] [akka:event-
driven:dispatcher:global-3] akka.dispatch.MonitorableThread: Created
thread akka:event-driven:dispatcher:global-3
[DEBUG] [2011-01-03 11:47:42,159] [akka:event-
driven:dispatcher:global-4] akka.dispatch.MonitorableThread: Created
thread akka:event-driven:dispatcher:global-4
[WARN] [2011-01-03 11:47:42,159] [http-8080-exec-5]
akka.actor.ActorRegistry$: Can't notify
[Actor[akka.camel.PublishRequestor:
468189c0-1772-11e0-8e91-005056c00008]] since it is not running.
[WARN] [2011-01-03 11:47:42,162] [akka:event-
driven:dispatcher:global-4] akka.actor.Actor$: Actor
[Actor[akka.camel.PublishRequestor:
468189c0-1772-11e0-8e91-005056c00008]] is shut down,
ignoring message [MessageInvocation[
message = ActorUnregistered(Actor[akka.camel.ConsumerPublisher:
46813ba0-1772-11e0-8e91-005056c00008])
receiver = Actor[akka.camel.PublishRequestor:
468189c0-1772-11e0-8e91-005056c00008]
sender = None
senderFuture = None]]
[WARN] [2011-01-03 11:47:42,162] [akka:event-
driven:dispatcher:global-4] akka.actor.Actor$: Actor
[Actor[akka.camel.PublishRequestor:
468189c0-1772-11e0-8e91-005056c00008]] is shut down,
ignoring message [MessageInvocation[
message = ActorUnregistered(Actor[XXXAuditXXX:
45ddf6c0-1772-11e0-8e91-005056c00008])
receiver = Actor[akka.camel.PublishRequestor:
468189c0-1772-11e0-8e91-005056c00008]
sender = None
senderFuture = None]]
[WARN] [2011-01-03 11:47:42,162] [akka:event-
driven:dispatcher:global-4] akka.actor.Actor$: Actor
[Actor[akka.camel.PublishRequestor:
468189c0-1772-11e0-8e91-005056c00008]] is shut down,
ignoring message [MessageInvocation[
message = ActorUnregistered(Actor[XXXDbXXX:
45a22640-1772-11e0-8e91-005056c00008])
receiver = Actor[akka.camel.PublishRequestor:
468189c0-1772-11e0-8e91-005056c00008]
sender = None
senderFuture = None]]
[INFO] [2011-01-03 11:47:42,163] [http-8080-exec-5]
akka.actor.Scheduler$: Starting up Scheduler
[WARN] [2011-01-03 11:47:42,165] [http-8080-exec-5]
akka.actor.ActorRegistry$: Can't notify
[Actor[akka.camel.PublishRequestor:
468189c0-1772-11e0-8e91-005056c00008]] since it is not running.
[INFO] [2011-01-03 11:47:42,176] [http-8080-exec-5]
akka.actor.ActorRegistry$: All actors have been shut down and
unregistered from ActorRegistry
[INFO] [2011-01-03 11:47:42,179] [http-8080-exec-5]
org.springframework.web.context.support.XmlWebApplicationContext:
Closing Root WebApplicationContext: startup date [Mon Jan 03 11:47:14
PST 2011]; root of context hierarchy
**********************
However I still get the same errors afterwards. I'm going to paste the
whole thing (slightly sanitized for confidentiality) here with risk of
it being really noisy, sorry if it is too much. Any suggestions? Sorry
if I'm being dense, it's just not clear to me how to properly
initialize/shutdown when using Spring in a web application. It looks
like the event dispatcher has created threads that are not shut down.
Is there something I should do manually for this or could it be a
configuration issue?
Thanks,
Kahli
[INFO] [2011-01-03 11:47:42,181] [http-8080-exec-5]
org.springframework.beans.factory.support.DefaultListableBeanFactory:
Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@69b8b810:
defining beans
[template,consumerTemplate,camelContext:beanPostProcessor,camelContext,akka.spring.CamelServiceFactoryBean#0,jms,jmsConfig,singleConnectionFactory,jmsConnectionFactory,akkaBoot,XXXDbXXX,XXXAuditXXX,XXXStructureXXX,testRemoteService,messageUtils,serverRoutes,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,propertyPlaceholderConfigurer,unifiedGBDatasource,unifiedGBHibernateConfigProperties,unifiedGBEntityManagerFactory];
root of factory hierarchy
[INFO] [2011-01-03 11:47:42,194] [http-8080-exec-5]
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean:
Closing JPA EntityManagerFactory for persistence unit 'UnifiedGB'
[INFO] [2011-01-03 11:47:42,195] [http-8080-exec-5]
org.hibernate.impl.SessionFactoryImpl: closing
[INFO] [2011-01-03 11:47:42,199] [http-8080-exec-5]
org.apache.camel.impl.DefaultCamelContext: Apache Camel 2.5.0
(CamelContext:camelContext) is shutting down
[INFO] [2011-01-03 11:47:42,203] [http-8080-exec-5]
org.apache.camel.impl.DefaultShutdownStrategy: Starting to graceful
shutdown 1 routes (timeout 300 seconds)
[INFO] [2011-01-03 11:47:42,206] [Camel Thread 0 - ShutdownTask]
org.apache.camel.impl.DefaultShutdownStrategy: Route: route1 suspended
and shutdown deferred, was consuming from: Endpoint[jms://
SOMEQUEUE.queue]
[INFO] [2011-01-03 11:47:42,397] [Camel Thread 0 - ShutdownTask]
org.apache.camel.impl.DefaultShutdownStrategy: Route: route1 shutdown
complete.
[INFO] [2011-01-03 11:47:42,397] [http-8080-exec-5]
org.apache.camel.impl.DefaultShutdownStrategy: Graceful shutdown of 1
routes completed in 0 seconds
[DEBUG] [2011-01-03 11:47:42,398] [http-8080-exec-5]
akka.camel.component.ActorProducer: Stopping producer:
Producer[actor://XXXDbXXX]
[DEBUG] [2011-01-03 11:47:42,399] [http-8080-exec-5]
akka.camel.component.ActorProducer: Stopping producer:
Producer[actor://XXXAuditXXX]
[DEBUG] [2011-01-03 11:47:42,399] [http-8080-exec-5]
akka.camel.component.ActorProducer: Stopping producer:
Producer[actor://XXXStructureXXX]
[INFO] [2011-01-03 11:47:42,400] [http-8080-exec-5]
org.apache.camel.impl.DefaultInflightRepository: Shutting down with no
inflight exchanges.
[INFO] [2011-01-03 11:47:42,401] [http-8080-exec-5]
org.apache.camel.impl.DefaultCamelContext: Uptime: 22.626 seconds
[INFO] [2011-01-03 11:47:42,401] [http-8080-exec-5]
org.apache.camel.impl.DefaultCamelContext: Apache Camel 2.5.0
(CamelContext: camelContext) is shutdown in 0.202 seconds
[INFO] [2011-01-03 11:47:42,403] [http-8080-exec-5]
akka.camel.CamelContextManager$: Camel context stopped
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/APPXXX] appears to have started a thread
named [New I/O server boss #2 ([id: 0x16dd5a9d, /127.0.0.1:9999])] but
has failed to stop it. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/APPXXX] appears to have started a thread
named [akka:event-driven:dispatcher:global-1] but has failed to stop
it. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/APPXXX] appears to have started a thread
named [akka:event-driven:dispatcher:global-2] but has failed to stop
it. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/APPXXX] appears to have started a thread
named [InactivityMonitor Async Task:
java.util.concurrent.ThreadPoolExecutor$Worker@76de839e] but has
failed to stop it. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/APPXXX] appears to have started a thread
named [akka:event-driven:dispatcher:global-3] but has failed to stop
it. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/APPXXX] appears to have started a thread
named [akka:event-driven:dispatcher:global-4] but has failed to stop
it. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/APPXXX] appears to have started a thread
named [akka:scheduler-0] but has failed to stop it. This is very
likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: The web application [/APPXXX] appears to have started a thread
named [TcpSocketClose: java.util.concurrent.ThreadPoolExecutor
$Worker@529df6cf] but has failed to stop it. This is very likely to
create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@3ba102ef]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@47c7b77e]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [com.sun.xml.bind.v2.ClassFactory$1@8dfd603])
and a value of type [java.util.WeakHashMap] (value [{class
org.apache.camel.model.ContextScanDefinition=java.lang.ref.WeakReference@660c1d35,
class
javax.xml.bind.annotation.adapters.CollapsedStringAdapter=java.lang.ref.WeakReference@2551b6ea,
class
org.apache.camel.spring.CamelContextFactoryBean=java.lang.ref.WeakReference@17bfcfca}])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [com.sun.xml.bind.v2.runtime.Coordinator
$1@31e2e2f4]) and a value of type [java.lang.Object[]] (value
[[Ljava.lang.Object;@26a21ac2]) but failed to remove it when the web
application was stopped. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [scala.util.DynamicVariable.$anon$1] (value
[scala.util.DynamicVariable$$anon$1@5c8aca5e]) and a value of type
[scala.None$] (value [None]) but failed to remove it when the web
application was stopped. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [org.jboss.netty.util.internal.ThreadLocalBoolean] (value
[org.jboss.netty.util.internal.ThreadLocalBoolean@27420a71]) and a
value of type [java.lang.Boolean] (value [true]) but failed to remove
it when the web application was stopped. This is very likely to create
a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [scala.util.DynamicVariable.$anon$1] (value
[scala.util.DynamicVariable$$anon$1@5c8aca5e]) and a value of type
[scala.None$] (value [None]) but failed to remove it when the web
application was stopped. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@3ba102ef]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@47c7b77e]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [scala.util.DynamicVariable.$anon$1] (value
[scala.util.DynamicVariable$$anon$1@5c8aca5e]) and a value of type
[scala.None$] (value [None]) but failed to remove it when the web
application was stopped. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@3ba102ef]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@47c7b77e]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [scala.util.DynamicVariable.$anon$1] (value
[scala.util.DynamicVariable$$anon$1@5c8aca5e]) and a value of type
[scala.None$] (value [None]) but failed to remove it when the web
application was stopped. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [scala.util.DynamicVariable.$anon$1] (value
[scala.util.DynamicVariable$$anon$1@5c8aca5e]) and a value of type
[scala.None$] (value [None]) but failed to remove it when the web
application was stopped. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [scala.util.DynamicVariable.$anon$1] (value
[scala.util.DynamicVariable$$anon$1@5c8aca5e]) and a value of type
[scala.None$] (value [None]) but failed to remove it when the web
application was stopped. This is very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@3ba102ef]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@47c7b77e]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@3ba102ef]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@47c7b77e]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@3ba102ef]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: The web application [/APPXXX] created a ThreadLocal with key
of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase
$1@47c7b77e]) and a value of type [java.lang.Boolean] (value [false])
but failed to remove it when the web application was stopped. This is
very likely to create a memory leak.
Jan 3, 2011 11:47:42 AM org.apache.catalina.startup.HostConfig
checkResources
INFO: Undeploying context [/APPXXX]
Jan 3, 2011 11:47:43 AM org.apache.catalina.loader.WebappClassLoader
loadClass
INFO: Illegal access: this web application instance has been stopped
already. Could not load akka.dispatch.MessageDispatcher$$anon$1$
$anonfun$run$1. The eventual following stack trace is caused by an
error thrown for debugging purposes as well as to attempt to terminate
the thread which caused the illegal access, and has no functional
impact.
java.lang.IllegalStateException
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1557)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1516)
at akka.dispatch.MessageDispatcher$$anon$1.run(MessageHandling.scala:
145)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:
441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)