scala.tools.reflect.ToolBoxError异常

时间:2015-05-07 16:18:27

标签: scala sbt sorm

我遇到了问题,无法解决问题。 今天,我在构建项目时遇到错误。主题中描述了此错误: Why do I get conflicting cross-version in sbt on one environment but not another?

据我所知,新版本的scala已经发布(2.12.0-M1)并且依赖性被破坏了。 这个问题的答案是覆盖" org.scala-lang"和" scala-compiler"使用代码的依赖:

dependencyOverrides += "org.scala-lang" % "scala-compiler" % scalaVersion.value

我的scalaVersion是scalaVersion := "2.11.1"。 这解决了构建项目的问题。 服务器运行成功,但是当我尝试调用DB对象(扩展Instance)来执行查询时,我得到一个异常:

play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.ExceptionInInitializerError]]
        at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.7.jar:2.3.7]
        at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.7.jar:2.3.7]
        at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.7.jar:2.3.7]
        at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.7.jar:2.3.7]
        at scala.Option.map(Option.scala:146) [scala-library-2.11.6.jar:na]
Caused by: java.lang.RuntimeException: java.lang.ExceptionInInitializerError
        at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:523) ~[play_2.11-2.3.7.jar:2.3.7]
        at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130) ~[play_2.11-2.3.7.jar:2.3.7]
        at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130) ~[play_2.11-2.3.7.jar:2.3.7]
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.3.7.jar:2.3.7]
        at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:129) ~[play_2.11-2.3.7.jar:2.3.7]
Caused by: java.lang.ExceptionInInitializerError: null
        at models.dao.UserDAO$.getUser(UserDAO.scala:32) ~[classes/:na]
        at controllers.User$$anonfun$login$1.apply(User.scala:82) ~[classes/:na]
        at controllers.User$$anonfun$login$1.apply(User.scala:80) ~[classes/:na]
        at play.api.mvc.ActionBuilder$$anonfun$apply$16.apply(Action.scala:433) ~[play_2.11-2.3.7.jar:2.3.7]
        at play.api.mvc.ActionBuilder$$anonfun$apply$16.apply(Action.scala:432) ~[play_2.11-2.3.7.jar:2.3.7]
Caused by: scala.tools.reflect.ToolBoxError: reflective compilation has failed: cannot initialize the compiler due to java.lang.VerifyError: scala/tools/reflect/ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal
        at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$api$.liftedTree1$1(ToolBoxFactory.scala:344) ~[scala-compiler-2.11.1.jar:na]
        at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$api$.compiler$lzycompute(ToolBoxFactory.scala:330) ~[scala-compiler-2.11.1.jar:na]
        at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$api$.compiler(ToolBoxFactory.scala:329) ~[scala-compiler-2.11.1.jar:na]
        at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$.liftedTree2$1(ToolBoxFactory.scala:356) ~[scala-compiler-2.11.1.jar:na]
        at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$.apply(ToolBoxFactory.scala:354) ~[scala-compiler-2.11.1.jar:na]
Caused by: java.lang.VerifyError: scala/tools/reflect/ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal
        at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$api$.liftedTree1$1(ToolBoxFactory.scala:334) ~[scala-compiler-2.11.1.jar:na]
        at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$api$.compiler$lzycompute(ToolBoxFactory.scala:330) ~[scala-compiler-2.11.1.jar:na]
        at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$api$.compiler(ToolBoxFactory.scala:329) ~[scala-compiler-2.11.1.jar:na]
        at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$.liftedTree2$1(ToolBoxFactory.scala:356) ~[scala-compiler-2.11.1.jar:na]
        at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$.apply(ToolBoxFactory.scala:354) ~[scala-compiler-2.11.1.jar:na]

我认为它与scala更新和配置问题有关,因为昨天我使用相同的服务,没有任何例外。

我的build.sbt

name := """XXXX"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.1"

dependencyOverrides += "org.scala-lang" % "scala-compiler" % scalaVersion.value

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  ws,
  "org.sorm-framework" % "sorm" % "0.3.18",
  "com.typesafe.play" %% "play-mailer" % "2.4.0",
  "com.typesafe.play" %% "play-json" % "2.3.7",
  "postgresql" % "postgresql" % "9.1-901.jdbc4",
  "com.sksamuel.scrimage" %% "scrimage-core" % "1.4.2",
  "com.sksamuel.scrimage" %% "scrimage-canvas" % "1.4.2",
  "com.sksamuel.scrimage" %% "scrimage-filters" % "1.4.2",
  "com.notnoop.apns" % "apns" % "1.0.0.Beta6",
  "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"
)

为什么会发生这种情况?

谢谢

1 个答案:

答案 0 :(得分:1)

我有同样的错误。将scalaVersion增加到2.11.6解决了它。