我被困在一個問題上,無法解決它。 今天,我在構建項目時遇到錯誤。主題描述了這個錯誤: Why do I get conflicting cross-version in sbt on one environment but not another?scala.tools.reflect.ToolBoxError異常
據我所知新版本的scala發佈(2.12.0-M1)並且依賴關係被打破。 對這個問題的答案是使用代碼覆蓋「org.scala琅」和「斯卡拉編譯」依賴:
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]
我認爲這是關係到斯卡拉更新和配置問題,因爲昨天我的工作使用相同的服務,沒有任何例外。
我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"
)
任何想法,爲什麼出現這種情況?
謝謝
這可能是特定於您的項目,所以很難說*爲什麼*沒有完整的'build.sbt',但*會發生什麼是你有幾個版本的scala-compiler.jar在類路徑 – dk14
談論鏈接問題,您是否嘗試清除緩存,目標和sbt的項目目標? – dk14
謝謝,我會考慮爲什麼在我的classpath中有幾個scala-compiler.jar。我還用'build.sbt'內容更新了任務 –