Scalatra关闭系统 - “没有这样的方法错误”

时间:2013-09-05 18:39:10

标签: scala akka atmosphere scalatra

我在使用Atmosphere框架的Scalatra中有一些代码,这些代码会在发出Web请求后导致系统崩溃。控制台显示从服务器发送到客户端的数据,但在此之后,将始终显示以下错误:

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)

我正在使用dispatch在m个actor中发出web请求。但是当我使用喷雾时,我得到了同样的信息。

以下是我发布网络请求的方式:

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

但是在将数据发送到客户端之后发生了错误(因为您可以在堆栈跟踪中看到对“broadcast”的调用。所以我认为这不是Web请求。

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"

我查看了scalatra的源代码,看起来未来的代码正在爆炸。我正在使用以下执行上下文,这可能是相关的:

implicit val ec: ExecutionContext = context.dispatcher

1 个答案:

答案 0 :(得分:2)

我将在这里猜测并说你正在拉入两个版本的akka​​-actor jar。你明确引用akka-testkit将会引入akka-actor 2.2.0 jar。我猜其他东西(也许是scalatra氛围)也在拉动akka-actor而不是2.2.0版本。您应该检查您的类路径,看看您是否确实有两个版本的akka​​-actor