如何使用 Akka 2.3.x 运行 Play 2.2.x? [英] How to run Play 2.2.x with Akka 2.3.x?

查看:25
本文介绍了如何使用 Akka 2.3.x 运行 Play 2.2.x?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法结合akka 2.3和玩2.2?现在,我在运行此类应用程序时遇到 AbstractMethodError.我需要在一个应用程序中同时使用它们,因为 Akka 2.3 带有非常有用的 akka 持久性模块,该模块非常可靠(与其前身相反),而且这种可靠性对我来说非常重要.我已经尝试从源代码编译 play 2.2.2 并将那里的 akka 依赖项更改为 2.3,但我仍然遇到相同的错误:

Is there any way to combine akka 2.3 and play 2.2? For now I'm getting AbstractMethodError while running such application. I need to have them both in one app because Akka 2.3 comes with very useful akka persistence module which is very reliable(in opposition to it's predecessor) and such reliability is really important in my case. I've tried compiling play 2.2.2 from sources and changing akka dependency there to 2.3 but i still get the same error:

[ERROR] [04/01/2014 09:42:26.105] [play-akka.actor.default-dispatcher-6] [ActorSystem(play)] Uncaught error from thread [play-akka.actor.default-dispatcher-6] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled
 java.lang.AbstractMethodError
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
    at akka.actor.ActorCell.invoke(ActorCell.scala:487)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
    at akka.dispatch.Mailbox.run(Mailbox.scala:220)
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

推荐答案

Akka 2.3 和 Play 2.2 只是二进制不兼容,这意味着您可以使用 Akka 2.3 作为依赖项编译 Play 2.2,并将其发布到您本地的 ivy 或公司存储库.

Akka 2.3 and Play 2.2 are just binary incompatible that means that you can compile Play 2.2 with Akka 2.3 as dependency and publish it to your local ivy or company repository.

就我而言,打补丁的 Play 版本没有发生 AbstractMethodError.尝试以这种方式打补丁:

In my case no AbstractMethodError occurred with the patched Play version. Try to patch Play this way:

  1. 检查标记的 Play 版本的源代码,例如 https://github.com/playframework/playframework/releases/tag/2.2.2
  2. 切换到 framework 文件夹(这是带有 project 子目录的 sbt 项目)
  3. 更改 Play 和 Akka 依赖项的版本号,例如 https://github.com/schleichardt/Play20/commit/14b45c44924ce5b3ef2159c772bc5b0544c94658
  4. sbt publishLocalsbt publish,对于后者你需要调整发布{Ivy,Maven}Repository 和 publishMavenStyle := trueframework/project/Build.scala
  5. (可选)除非您已将 Play 的补丁版本发布到本地 Ivy 存储库(使用 publishLocal),否则您需要将解析器添加到 build.sbtproject/plugins.sbt
  6. project/plugins.sbt中设置打补丁的Play sbt插件,例如,addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.2-akka-2.3.1")
  1. Checkout the source code of a tagged Play version, e.g., https://github.com/playframework/playframework/releases/tag/2.2.2
  2. Switch into the framework folder (that's the sbt project with the project subdirectory)
  3. Change the version number of Play and Akka dependency, e.g., https://github.com/schleichardt/Play20/commit/14b45c44924ce5b3ef2159c772bc5b0544c94658
  4. sbt publishLocal or sbt publish, for the latter you need to adjust publishing{Ivy,Maven}Repository and publishMavenStyle := true in framework/project/Build.scala
  5. (optional) Unless you've published the patch version of Play to your local Ivy repository (using publishLocal), you need to add a resolver to build.sbt and project/plugins.sbt
  6. In project/plugins.sbt set the patched Play sbt plugin, e.g., addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.2-akka-2.3.1")

演示位于 https://github.com/schleichardt/event-sourcing-with-the-play-framework/tree/bf171720c43a1349555726cb11cffae4d967cc4b.打补丁的 Play 版本的源代码在 https://github.com/schleichardt/Play20/tree/2.2.2-akka-2.3.1.

A demo is in https://github.com/schleichardt/event-sourcing-with-the-play-framework/tree/bf171720c43a1349555726cb11cffae4d967cc4b. The source code for the patched Play version is in https://github.com/schleichardt/Play20/tree/2.2.2-akka-2.3.1.

另请参阅https://stackoverflow.com/a/22651261/1575096,了解有关 Akka 2.3 编译的问题播放,Jeff May 无法使用 WS 库.

Refer also to https://stackoverflow.com/a/22651261/1575096 for problems with an Akka 2.3 compiled Play, Jeff May was not able to use the WS library.

请记住,其他库,例如带有 Play 迭代器的 ReactiveMongo,也可能依赖于 Play 库,并且可能会将未打补丁的版本加载到类路径中.在这种情况下,像 "group" %% "library" % "version" exclude("com.typesafe.play", "play") 会有所帮助.如果是 ReactiveMongo,你也需要为 Akka 2.3 编译它.

Keep in mind that other libraries, for example ReactiveMongo with Play iteratees, may also depend on Play libraries and may load the unpatched version into the class path. In that case something like "group" %% "library" % "version" exclude("com.typesafe.play", "play") would help. In case of ReactiveMongo you need to compile it for Akka 2.3, too.

使用 sbt 'show libraryDependencies',您可以检查实际的依赖项及其版本.

With sbt 'show libraryDependencies' you can inspect the actual dependencies and their versions.

这篇关于如何使用 Akka 2.3.x 运行 Play 2.2.x?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆