Akka startup/shutdown in Spring based web application

1,251 views
Skip to first unread message

Kahli Burke

unread,
Dec 31, 2010, 4:44:21 PM12/31/10
to Akka User List
I am trying to figure out how to get Akka to properly shutdown when my
web application is undeployed as well as get it to shutdown properly
when the servlet container (Tomcat 7.05) shuts down.

It seems that there is some piece of the system that is not responding
to the shutdown properly. I am configuring Akka using Spring and
Camel.

<!-- Create akka camel integration -->
<camel:camelContext id="camelContext">
<!-- This will scan for spring defined components that inherit
from RouteBuilder -->
<camel:contextScan/>
</camel:camelContext>
<akka:camel-service>
<akka:camel-context ref="camelContext" />
</akka:camel-service>

When shutting down I get many messages like:

SEVERE: The web application [/******] 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.

as well as

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)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ScheduledThreadPoolExecutor
$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor
$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)

Is there something I need to do, for example in the web.xml or spring
configuration to properly shut down Akka? I saw reference to a servlet
listener:

<listener>
<listener-class>akka.servlet.Initializer</listener-class>
</listener>

but that does not seem to resolve the problem, plus I think this is
actually duplicating some start up code.

Any advice? Thanks!

√iktor Klang

unread,
Dec 31, 2010, 5:50:03 PM12/31/10
to akka...@googlegroups.com

Hi,

What version are you running?

I don't know what cleanup code you've written but try
ActorRegistry.shutdownAll


--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.

Kahli Burke

unread,
Jan 3, 2011, 2:21:27 PM1/3/11
to Akka User List


On Dec 31 2010, 2:50 pm, √iktor Klang <viktor.kl...@gmail.com> wrote:
> Hi,
>
> What version are you running?
>
> I don't know what cleanup code you've written but try
> ActorRegistry.shutdownAll
>

This is 1.0-RC2. I will experiment some more with that... I should
register my own servlet listener for this?

Thanks!

Kahli

√iktor Klang

unread,
Jan 3, 2011, 2:42:13 PM1/3/11
to akka...@googlegroups.com

Yes, but you can probably just extend the default one.

On Jan 3, 2011 8:25 PM, "Kahli Burke" <kahli...@wintermutesys.com> wrote:



On Dec 31 2010, 2:50 pm, √iktor Klang <viktor.kl...@gmail.com> wrote:
> Hi,
>

> What version are y...

This is 1.0-RC2. I will experiment some more with that... I should
register my own servlet listener for this?

Thanks!

Kahli


--

You received this message because you are subscribed to the Google Groups "Akka User List" group.

To...

Kahli Burke

unread,
Jan 3, 2011, 2:58:54 PM1/3/11
to Akka User List


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)

√iktor Klang

unread,
Jan 3, 2011, 3:12:01 PM1/3/11
to akka...@googlegroups.com
Try to add Scheduler.shutdown to your listener as well.

Also looks like Tomatcs aggressive memory leak preventer is yelling.

--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.




--
Viktor Klang,
Code Connoisseur
Work:   Scalable Solutions
Code:   github.com/viktorklang
Follow: twitter.com/viktorklang
Read:   klangism.tumblr.com

Kahli Burke

unread,
Jan 4, 2011, 8:08:00 PM1/4/11
to Akka User List


On Jan 3, 12:12 pm, √iktor Klang <viktor.kl...@gmail.com> wrote:
> Try to add Scheduler.shutdown to your listener as well.
>
> Also looks like Tomatcs aggressive memory leak preventer is yelling.
>

I've done some more investigation with this. I still don't really like
what I have. In particular the way the RemoteServer is managed by the
Spring integration code is problematic. For now I have this:

public class AkkaSpringShutdownListener implements DisposableBean {
private Logger log =
LoggerFactory.getLogger(AkkaSpringShutdownListener.class);

@Override
public void destroy() throws Exception {

// I don't like putting in Thread.wait here but I'm not sure
how to properly wait for
// services to shut down.
log.info("Akka Spring ShutdownListener started shutting down
Akka services ...");
while(ActorRegistry.actors().length > 0) {
ActorRegistry.shutdownAll();
Thread.sleep(1000);
}
Scheduler.shutdown();
Thread.sleep(1000);

//TODO: Spring services don't keep track of remote servers or
which port.... assume 9999 for now
// but this needs work.
Option<RemoteServer> serverOption =
RemoteServer.serverFor("localhost", 9999);
if (!(serverOption.isEmpty())) {
serverOption.get().shutdown();
}
Thread.sleep(1000);
log.info("Akka Spring ShutdownListener finished shutting down
Akka services ...");
}
}

Issues with this are:

- If I don't put those sleep commands in, the threads never seem to
get shutdown. I think perhaps the scheduler is being shutdown before
all the messages can be delivered to the actors, but I'm not really
sure about that. I noticed that it was working when watching in the
debugger but not when I disconnected. If you guys have any more advice
on this it would be appreciated.

- When starting the remote actors through Spring, the ActorFactoryBean
creates the RemoteServer with the specified server and port. However
nothing seems to keep track of the RemoteServer objects that have been
created, other than a private Map in the RemoteServer (or RemoteNode,
can't remember). This may be changed some with the brand new changes
to the remote API Viktor checked in, I couldn't tell immediately. It
would be great to be able to ask Akka to shut down any and all remote
servers simultaneously. Is there any way to do that with your new API?

Thanks!

√iktor Klang

unread,
Jan 5, 2011, 4:05:57 AM1/5/11
to akka...@googlegroups.com

What messages?
Actor.stop does not wait for all messages to finish processing for that actor.
 
but I'm not really
sure about that. I noticed that it was working when watching in the
debugger but not when I disconnected. If you guys have any more advice
on this it would be appreciated.

- When starting the remote actors through Spring, the ActorFactoryBean
creates the RemoteServer with the specified server and port. However
nothing seems to keep track of the RemoteServer objects that have been
created, other than a private Map in the RemoteServer (or RemoteNode,
can't remember). This may be changed some with the brand new changes
to the remote API Viktor checked in, I couldn't tell immediately. It
would be great to be able to ask Akka to shut down any and all remote
servers simultaneously. Is there any way to do that with your new API?

Yes, that will change.

Java: Actors.remote().shutdown();
Scala: Actor.remote.shutdown
 

Thanks!


--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.

Jonas Bonér

unread,
Jan 5, 2011, 4:35:34 AM1/5/11
to akka...@googlegroups.com
> What messages?
> Actor.stop does not wait for all messages to finish processing for that
> actor.
>

You can check for that yourself:

if (self.mailboxSize == 0) self.stop

--
Jonas Bonér

Specialist at Large
work: http://scalablesolutions.se
code: http://akka.io
blog: http://jonasboner.com
twtr: @jboner

Kahli Burke

unread,
Jan 5, 2011, 6:09:56 PM1/5/11
to Akka User List
On Jan 5, 1:35 am, Jonas Bonér <jo...@jonasboner.com> wrote:
> > What messages?
> > Actor.stop does not wait for all messages to finish processing for that
> > actor.
>
> You can check for that yourself:
>
> if (self.mailboxSize == 0) self.stop
>

That was just a conjecture about the reason the threads were not shut
down if I run the code I posted above but simply take the
Thread.sleep(1000) statements out. The way I'm testing this is to
simply deploy and undeploy, I shouldn't actually have any messages
being processed by any of the actors in the system. It wasn't obvious
to me why this occurred but it seemed to be consistent behavior. The
dispatcher threads would still exist and therefore my application
would not shut down all the way. So there seems to be some race
condition in the way these are shut down. I can check with jstack
after undeployment and I still see several of these:


"akka:event-driven:dispatcher:global-5" daemon prio=5 tid=1028e9000
nid=0x124648000 waiting on condition [124647000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <108989a88> (a
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
at java.util.concurrent.locks.AbstractQueuedSynchronizer
$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
at
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:
399)
at
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:
947)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:680)
at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:185)

I can keep the sleep statements in there, but it doesn't make me feel
good and I wanted to point it out to you in case it was something you
wanted to know about and also in case you had any advice on something
I was doing wrong.

Thanks,

Kahli
Reply all
Reply to author
Forward
0 new messages