NoClassDefFoundError => ClassPath$JavaContext when using play start

末鹿安然 提交于 2019-12-11 03:22:05

问题


I've made a little Scala, Play2.0.2 application.

It works fine when i use play run command, but when i use play start or play clean compile stage + target/start, when trying to do a MongoDB insertion with Casbah/Salat, i get the following stack:

[info] application - Can't create user 
java.lang.NoClassDefFoundError: scala/tools/nsc/util/ClassPath$JavaContext
    at scala.tools.scalap.scalax.rules.scalasig.ScalaSigParser$.scalaSigFromAttribute(ScalaSig.scala:35) ~[scalap-2.9.1.jar:na]
    at scala.tools.scalap.scalax.rules.scalasig.ScalaSigParser$.parse(ScalaSig.scala:38) ~[scalap-2.9.1.jar:na]
    at com.novus.salat.util.ScalaSigUtil$$anonfun$parseScalaSig0$2.apply(ScalaSigUtil.scala:73) ~[salat-util_2.9.1-0.0.8-SNAPSHOT.jar:0.0.8-SNAPSHOT]
    at com.novus.salat.util.ScalaSigUtil$$anonfun$parseScalaSig0$2.apply(ScalaSigUtil.scala:73) ~[salat-util_2.9.1-0.0.8-SNAPSHOT.jar:0.0.8-SNAPSHOT]
    at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]
    at com.novus.salat.util.ScalaSigUtil$.parseScalaSig0(ScalaSigUtil.scala:73) ~[salat-util_2.9.1-0.0.8-SNAPSHOT.jar:0.0.8-SNAPSHOT]
Caused by: java.lang.ClassNotFoundException: scala.tools.nsc.util.ClassPath$JavaContext
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[na:1.7.0_01]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_01]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_01]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_01]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423) ~[na:1.7.0_01]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.7.0_01]

Any idea?


回答1:


It seems the Scala compiler is needed by Scalap so i added the dependency: "org.scala-lang" % "scala-compiler" % "2.9.1"

And it works fine.

Which leads me to another question: Why do i need Scala compiler at runtime? (Play2/Salat with Scalap dependency)




回答2:


The problem could also occur if you miss the Async support configuration when using Spring MVC in the context.xml



来源:https://stackoverflow.com/questions/11819518/noclassdeffounderror-classpathjavacontext-when-using-play-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!