Question about running Akka/Mist in a Jetty container

158 views
Skip to first unread message

Reggie

unread,
Sep 15, 2011, 2:44:03 AM9/15/11
to Akka User List
Hi there. I am using Akka 1.2-RC6. I was able to take the Mist example
in the docs and figure out how to make it work using a Maven build and
running 'mvn jetty:run'. I have two minor problems that I would like
help in troubleshooting.

First Startup is Slooooooooooow. I get the jetty starting message:

[INFO] Starting jetty 8.0.0.M2 ...
2011-09-14 23:30:28.705:INFO::jetty-8.0.0.M2
2011-09-14 23:30:32.062:INFO::No Transaction manager found - if your
webapp requires one, please configure one.

Then after the nice big Akka logo prints I get this:

Starting Akka...
Akka started successfully
2011-09-14 23:31:03.031:INFO::Started
SelectChann...@0.0.0.0:8080

Thats almost a minute. I'm running this on an I5 MBP with 8GB of RAM.
Any clues as to why its taking so long to startup?

Second, on shutdown I get the exception below after I control-C the
'mvn jetty:run' command:

2011-09-14 18:16:22.142:WARN::FAILED
JettyWebAppContext@1a06f956@1a06f956/,file:akka-http-example/src/main/
webapp/,file:akka-http-example/src/main/webapp/:
java.lang.IllegalStateException: Shutdown in progress
2011-09-14 18:16:22.142:WARN::FAILED
ContextHandlerCollection@11e04129: java.lang.IllegalStateException:
Shutdown in progress
2011-09-14 18:16:22.142:WARN::FAILED HandlerCollection@19d5f3ea:
java.lang.IllegalStateException: Shutdown in progress
[ERROR] [9/14/11 6:16 PM] [Thread-3] [Switch] Shutdown in progress
java.lang.IllegalStateException: Shutdown in progress
at
java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:
39)
at java.lang.Runtime.addShutdownHook(Runtime.java:192)
at akka.actor.Actor$.shutdownHook(Actor.scala:122)
at akka.util.AkkaLoader$$anonfun$shutdown$1.apply$mcV
$sp(AkkaLoader.scala:41)
at akka.util.Switch.liftedTree1$1(LockUtil.scala:126)
at akka.util.Switch.transcend(LockUtil.scala:125)
at akka.util.Switch.switchOff(LockUtil.scala:137)
at akka.util.AkkaLoader.shutdown(AkkaLoader.scala:37)
at akka.servlet.Initializer.contextDestroyed(Initializer.scala:29)
at
org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:
706)
at
org.eclipse.jetty.servlet.ServletContextHandler.doStop(ServletContextHandler.java:
149)
at org.eclipse.jetty.webapp.WebAppContext.doStop(WebAppContext.java:
536)
at
org.mortbay.jetty.plugin.JettyWebAppContext.doStop(JettyWebAppContext.java:
183)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:
80)
at
org.eclipse.jetty.server.handler.HandlerCollection.doStop(HandlerCollection.java:
247)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:
80)
at
org.eclipse.jetty.server.handler.HandlerCollection.doStop(HandlerCollection.java:
247)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:
80)
at
org.eclipse.jetty.server.handler.HandlerWrapper.doStop(HandlerWrapper.java:
106)
at org.eclipse.jetty.server.Server.doStop(Server.java:301)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:
80)
at
org.eclipse.jetty.util.thread.ShutdownThread.run(ShutdownThread.java:
124)

[INFO] 2011-09-14 18:16:22.197:WARN::FAILED
org.mortbay.jetty.plugin.JettyServer@5ca801b0:
java.lang.IllegalStateException: Shutdown in progress
Jetty server exiting.
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 1:24.562s
[INFO] Finished at: Wed Sep 14 18:16:22 PDT 2011
[INFO] Final Memory: 19M/81M
[INFO]
------------------------------------------------------------------------
Shutting down Akka...
2011-09-14 18:16:22.698:WARN::FAILED
JettyWebAppContext@1a06f956@1a06f956/,file:akka-http-example/src/main/
webapp/,file:akka-http-example/src/main/webapp/:
java.lang.IllegalStateException: Shutdown in progress
2011-09-14 18:16:22.698:WARN::FAILED
ContextHandlerCollection@11e04129: java.lang.IllegalStateException:
Shutdown in progress
2011-09-14 18:16:22.698:WARN::FAILED HandlerCollection@19d5f3ea:
java.lang.IllegalStateException: Shutdown in progress
2011-09-14 18:16:22.698:WARN::FAILED
org.mortbay.jetty.plugin.JettyServer@5ca801b0:
java.lang.IllegalStateException: Shutdown in progress


I looks like AkkaLoader.shutdown() calls Actor.shutdownHook.run.
Actor.shutdownHook is a lazy val and it looks like this shutdown is
the first time it gets used. As part of its creation, shutdownHook
calls Runtime.getRuntime.addShutdownHook(new Thread(hook)). Since its
doing this at shutdown time, it looks like the java runtime is not
happy doing that. Any suggestions on how to resolve this?

Other than that, things look great. I needed to do a little hunting
around to get this to work since my web.xml needed the correct
listener but other than that, so far so good.

Thanks for any help.

-Reggie

√iktor Ҡlang

unread,
Sep 15, 2011, 4:03:14 PM9/15/11
to akka...@googlegroups.com
Hi Reggie, I think you need to do some investigation of your own, I don't see how anybody could make any assumptions about what's slow on your machine.

Check your app during boot in JConsole and see what looks strange.

Hope that helps,

Cheers,



--
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

Akka Tech Lead
Typesafe - Enterprise-Grade Scala from the Experts

Twitter: @viktorklang

Reggie

unread,
Sep 15, 2011, 6:06:50 PM9/15/11
to Akka User List
I figured that I would have to dig into that, but at the end of the
posted an exception stack trace for an IllegalStateException where it
looks like AkkaLoader.shutdown() calls Actor.shutdownHook.run.
Actor.shutdownHook is a lazy val and it looks like this shutdown is
the first time it gets used. As part of its creation, shutdownHook
calls Runtime.getRuntime.addShutdownHook(new Thread(hook)). Since its
doing this at shutdown time, it looks like the java runtime is not
happy doing that. Any suggestions on how to resolve this?

Thanks for the help.

-Reggie

On Sep 15, 1:03 pm, √iktor Ҡlang <viktor.kl...@gmail.com> wrote:
> Hi Reggie, I think you need to do some investigation of your own, I don't
> see how anybody could make any assumptions about what's slow on your
> machine.
>
> Check your app during boot in JConsole and see what looks strange.
>
> Hope that helps,
>
> Cheers,
> √
>
>
>
>
>
>
>
>
>
> On Thu, Sep 15, 2011 at 8:44 AM, Reggie <reggie.pe...@gmail.com> wrote:
> > Hi there. I am using Akka 1.2-RC6. I was able to take the Mist example
> > in the docs and figure out how to make it work using a Maven build and
> > running 'mvn jetty:run'. I have two minor problems that I would like
> > help in troubleshooting.
>
> > First Startup is Slooooooooooow. I get the jetty starting message:
>
> > [INFO] Starting jetty 8.0.0.M2 ...
> > 2011-09-14 23:30:28.705:INFO::jetty-8.0.0.M2
> > 2011-09-14 23:30:32.062:INFO::No Transaction manager found - if your
> > webapp requires one, please configure one.
>
> > Then after the nice big Akka logo prints I get this:
>
> > Starting Akka...
> > Akka started successfully
> > 2011-09-14 23:31:03.031:INFO::Started
> > SelectChannelConnec...@0.0.0.0:8080
> Typesafe <http://www.typesafe.com/> - Enterprise-Grade Scala from the
> Experts
>
> Twitter: @viktorklang

√iktor Ҡlang

unread,
Sep 15, 2011, 7:06:25 PM9/15/11
to akka...@googlegroups.com
On Fri, Sep 16, 2011 at 12:06 AM, Reggie <reggie...@gmail.com> wrote:
I figured that I would have to dig into that, but at the end of the
posted an exception stack trace for an IllegalStateException where it
looks like AkkaLoader.shutdown() calls Actor.shutdownHook.run.
Actor.shutdownHook is a lazy val and it looks like this shutdown is
the first time it gets used. As part of its creation, shutdownHook
calls Runtime.getRuntime.addShutdownHook(new Thread(hook)). Since its
doing this at shutdown time, it looks like the java runtime is not
happy doing that. Any suggestions on how to resolve this?

I can remove the shutdown hook, shouldn't be needed anymore. Was used to prevent Configgy from leaking memory.
 



--
Typesafe - Enterprise-Grade Scala from the Experts

Twitter: @viktorklang

Reggie

unread,
Sep 15, 2011, 9:45:39 PM9/15/11
to Akka User List
That would be great. Thanks. I will investigate the slowness. Note
that I'm just using the Mist example from the akka docs, starting up
the server and feeding it GETs and POSTs.

-Reggie

On Sep 15, 4:06 pm, √iktor Ҡlang <viktor.kl...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages