升级到Play Framework 2.2 Securesocial问题

时间:2014-02-01 11:53:45

标签: scala playframework-2.0 securesocial

您好我正在尝试升级到Play 2.2,并且在使用securesocial工作时遇到了一些问题。

我正在使用论坛中建议的最新快照,但收到以下错误。验证错误表示二进制文件与我正在使用的版本之间某处的编译源不兼容。我尝试在java 1.6和1.7之间切换,但得到同样的问题。 我知道securesocial只适用于Play 2.1,但有一些使用securesocial快照的Play 2.2的例子。 也许我应该再次降级。

我的Build.scala

object ApplicationBuild extends Build {

  val appName = "rm-play"
  val appVersion = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    // Add your project dependencies here,
    javaCore,
    javaJdbc,
    javaEbean,
    "com.google.guava" % "guava" % "15.0",
    "org.codehaus.jackson" % "jackson-core-asl" % "1.9.13",
    "com.dbdeploy" % "maven-dbdeploy-plugin" % "3.0M3",
    "postgresql" % "postgresql" % "9.1-901.jdbc4",
    "joda-time" % "joda-time" % "2.3",
    "com.github.mumoshu" % "play2-memcached_2.10" % "0.3.0.3",
    "net.spy" % "spymemcached" % "2.9.1",
    "com.amazonaws" % "aws-java-sdk"% "1.6.11",
    "ws.securesocial" %% "securesocial" % "master-SNAPSHOT"
  )


  val main = play.Project(appName, appVersion, appDependencies).settings(
    resolvers += Resolver.sonatypeRepo("snapshots"),
    javacOptions in Compile ++= Seq("-source", "1.7", "-target", "1.7")
  )

} 

plugin.sbt

logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % System.getProperty("play.version")

           _
 _ __ | | __ _ _  _
| '_ \| |/ _' | || |
|  __/|_|\____|\__ /
|_|            |__/

play 2.2.2-RC2 built with Scala 2.10.3 (running Java 1.7.0_04), http://www.playframework.com

> Type "help play" or "license" for more information.
> Type "exit" or use Ctrl+D to leave this console.

[rm-play] $ run
[info] Updating {file:/Users/zola/Development/play/receipt-manager/rm-play/}rm-play...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.

--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
[info] play - Listening for HTTPS on port /0:0:0:0:0:0:0:0:9443

(Server started, use Ctrl+D to stop and go back to the console...)

[warn] play - Using generated key with self signed certificate for HTTPS. This should not be used in production.
[info] Compiling 12 Scala sources and 19 Java sources to /Users/zola/Development/play/receipt-manager/rm-play/target/scala-2.10/classes...
[info] Compiling 8 Scala sources to /Users/zola/Development/play/receipt-manager/rm-play/target/scala-2.10/classes...
[error] application - 

! @6h5hbne72 - Internal server error, for (GET) [/login] ->

play.api.PlayException: Cannot load plugin[Plugin [service.PersistantUserService] cannot been instantiated.]
    at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:159) ~[play_2.10.jar:2.2.2-RC2]
    at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:128) ~[play_2.10.jar:2.2.2-RC2]
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) ~[scala-library.jar:na]
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) ~[scala-library.jar:na]
    at scala.collection.immutable.List.foreach(List.scala:318) ~[scala-library.jar:na]
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:244) ~[scala-library.jar:na]
Caused by: java.lang.VerifyError: Stack map does not match the one at exception handler 188 in method service.PersistantUserService.doSave(Lsecuresocial/core/java/Token;)V at offset 116
    at java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:1.7.0_04]
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404) ~[na:1.7.0_04]
    at java.lang.Class.getConstructor0(Class.java:2714) ~[na:1.7.0_04]
    at java.lang.Class.getConstructor(Class.java:1674) ~[na:1.7.0_04]
    at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:130) ~[play_2.10.jar:2.2.2-RC2]
    at play.api.WithDefaultPlugins$$anonfun$plugins$1$$anonfun$apply$9.apply(Application.scala:128) ~[play_2.10.jar:2.2.2-RC2]

2 个答案:

答案 0 :(得分:2)

事实证明它比编译版本的差异更加无害。

导致错误的原因是下面的行,将其更改为使用该方法而不是字段更正了问题。

在日志中我发现了错误

  

原因:       类型'securesocial / core / java / Token'(当前帧,locals [4])不能分配给'model / LocalToken'(堆栈映射,locals [4])

localToken.uuid = token.uuid;

更改为以下解决了问题。

localToken.uuid = token.getUuid();

我不确定为什么这有助于我对scala没有那么多经验但是字段调用会生成方法,也许这就是导致问题。

答案 1 :(得分:1)

SecuresSocial 2.1.3和master-SNAPSHOT应该适用于Play 2.2.1。我认为造成这个问题的原因是你的UserService实现正在为1.7编译,但试图加载它的代码是为1.6编译的。

默认情况下,Scala 2.10会生成1.6的字节码。您可以生成1.7,但据我所知,该功能是实验性的。 1.6是优选的。我将更改sbt文件以生成1.6字节码。这应该有效。