sorm h2 DB for play framework scala - NoSuchMethodError

时间:2014-10-06 09:50:05

标签: scala playframework h2 sorm

当我遵循play-scala模板教程时,我遇到了这个错误:

[error] play - Cannot invoke the action, eventually got an error: java.lang.RuntimeException: java.lang.NoSuchMethodError: scala.reflect.api.Types$TypeApi.members()Lscala/reflect/api/Scopes$ScopeApi;
[error] application - 

! @6jmiof8bp - Internal server error, for (POST) [/provision] ->

play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.NoSuchMethodError: scala.reflect.api.Types$TypeApi.members()Lscala/reflect/api/Scopes$ScopeApi;]]
    at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.4.jar:2.3.4]
    at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.4.jar:2.3.4]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.4.jar:2.3.4]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.4.jar:2.3.4]
    at scala.Option.map(Option.scala:145) [scala-library-2.11.1.jar:na]
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: scala.reflect.api.Types$TypeApi.members()Lscala/reflect/api/Scopes$ScopeApi;
    at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:523) ~[play_2.11-2.3.4.jar:2.3.4]
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130) ~[play_2.11-2.3.4.jar:2.3.4]
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130) ~[play_2.11-2.3.4.jar:2.3.4]
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.3.4.jar:2.3.4]
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:129) ~[play_2.11-2.3.4.jar:2.3.4]
Caused by: java.lang.NoSuchMethodError: scala.reflect.api.Types$TypeApi.members()Lscala/reflect/api/Scopes$ScopeApi;
    at sorm.reflection.ScalaApi$TypeApi.members(ScalaApi.scala:11) ~[sorm-0.3.13.jar:na]
    at sorm.reflection.ScalaApi$TypeApi.properties(ScalaApi.scala:13) ~[sorm-0.3.13.jar:na]
    at sorm.reflection.Reflection.properties(Reflection.scala:31) ~[sorm-0.3.13.jar:na]
    at sorm.core.Initialization$.sorm$core$Initialization$$checkType$1(Initialization.scala:75) ~[sorm-0.3.13.jar:na]
    at sorm.core.Initialization$.recursiveEntities$1(Initialization.scala:79) ~[sorm-0.3.13.jar:na]

我在DB.save(person)方法Application.scala

上添加此行provision时遇到此错误

我的数据库对象如下所示:

object MemDB extends Instance(entities = Seq(Entity[Person]()), url ="jdbc:h2:mem:play") {}

我还删除了application.conf文件

上的评论
 db.default.driver=org.h2.Driver
 db.default.url="jdbc:h2:mem:play"

我无法弄清楚如何修复此错误。我只是按照playframework websito中的视频教程来播放框架和scala。我也尝试将url更改为jdbc:h2:mem:test就像教程建议的那样。我使用以下版本

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.4")
libraryDependencies += "org.sorm-framework" % "sorm" % "0.3.13"
libraryDependencies += "com.h2database" % "h2" % "1.4.181"
scalaVersion := "2.11.1"

1 个答案:

答案 0 :(得分:0)

SORM仅与Play版本2.1兼容。你的问题必须由此造成。

此处a related ticket