NoClassDefFoundError =>使用play start时的ClassPath $ JavaContext

时间:2012-08-05 19:44:13

标签: scala mongodb playframework-2.0 casbah salat

我做了一点Scala,Play2.0.2应用程序。

当我使用play run命令时它工作正常,但是当我使用play startplay clean compile stage + target/start时,当尝试使用Casbah / Salat进行MongoDB插入时,我得到以下堆栈:

[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]

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

似乎Scalap需要Scala编译器,所以我添加了依赖: “org.scala-lang”%“scala-compiler”%“2.9.1”

它运作正常。

这引出了另一个问题: Why do i need Scala compiler at runtime? (Play2/Salat with Scalap dependency)

答案 1 :(得分:1)

如果在context.xml中使用Spring MVC时错过了Async支持配置,也会出现此问题