Domanda

I have some code in Scalatra using Atmosphere framework that keeps causing the system to crash after a web request is made. The console shows the data being sent from server to client, but straight after it the following error always appears:

Uncaught error from thread [default-akka.actor.default-dispatcher-11] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[default]
java.lang.NoSuchMethodError: akka.actor.ActorSystem.dispatcher()Lakka/dispatch/MessageDispatcher;
    at org.scalatra.atmosphere.package$.jucFuture2akkaFuture(package.scala:29)
    at org.scalatra.atmosphere.ScalatraBroadcaster.broadcast(ScalatraBroadcaster.scala:19)

I am using dispatch to make the web requests inside m actors. But I got the same message when I was using spray.

Here is how I make the web request:

Http(Req(_.setUrl(fullUrl))) map {response =>

But the error happens after data has been sent to the client (as you can see the call to "broadcast" in the stack trace. So I don't think it is the web request.

My project build file:

 lazy val project = Project (
    "",
    file("."),
    settings = Defaults.defaultSettings ++ ScalatraPlugin.scalatraWithJRebel ++ scalateSettings ++ assemblySettings ++ Seq(
      organization := Organization,
      name := Name,
      version := Version,
      scalaVersion := ScalaVersion,
      resolvers += Classpaths.typesafeReleases,
      test in assembly := {},
      jarName in assembly := "",
      mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
        {
          case PathList(xs) if xs.equals("about.html") => MergeStrategy.first
          case x => old(x)
        }
      },
      libraryDependencies ++= Seq(
        "org.scalatra" %% "scalatra" % ScalatraVersion,
        "org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
        "org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
        "ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
        "org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container;compile",
        "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test;compile" artifacts (Artifact("javax.servlet", "jar", "jar")),
        "org.scalatra" %% "scalatra-atmosphere" % "2.2.1",
        "org.scalatra" %% "scalatra-json" % "2.2.1",
        "org.json4s"   %% "json4s-jackson" % "3.2.4",
        "org.eclipse.jetty" % "jetty-websocket" % "8.1.10.v20130312" % "container;compile",
        "org.scalatest" % "scalatest_2.10" % "2.0.M6-SNAP17",
        "com.typesafe.akka" % "akka-testkit_2.10" % "2.2.0",
        "joda-time" % "joda-time" % "2.3",
        "com.github.nscala-time" %% "nscala-time" % "0.6.0",
        "com.cloudphysics" % "jerkson_2.10" % "0.6.3",
          "net.databinder.dispatch" %% "dispatch-core" % "0.11.0"

I looked at the source code of scalatra and it appears that it is code inside the future that is blowing up. I am using the following execution context, which may be relevant:

implicit val ec: ExecutionContext = context.dispatcher
È stato utile?

Soluzione

I'm going to take a guess here and say that you are pulling in two versions of the akka-actor jar. You explicitly referencing akka-testkit is going to pull in the akka-actor 2.2.0 jar. I'm guessing that something else (maybe scalatra atmosphere) is also pulling in akka-actor and not the 2.2.0 version. You should check your classpath and see if you indeed to have two versions of akka-actor

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top