使用SBT嵌入式Jetty和scalatra / scalate时出现“org.fusesource.scalate.TemplateException:loader constraint violation”

时间:2011-04-12 16:31:42

标签: scala jetty sbt scalate scalatra

昨天我在SBT中使用嵌入式'jetty-run'任务时开始出现此错误。我将我的代码恢复到以前的版本,它仍然在发生。

请注意,我将应用程序打包并将其部署在实际的jetty实例中,但我没有收到错误。在我的项目中添加一些依赖项后,我开始收到此错误(可能相关也可能不相关),但之后已将其删除。

我尝试'clean''clead-lib'和'clean-cache'以及清理我的〜/ .m2 / repository,〜/ .ivy2 / cache和project / boot目录。

有人还有其他想法吗?

正在爆炸的界线是:

templateEngine.layout(uri, Map("flash" -> flash))

更多的堆栈跟踪如下:

org.fusesource.scalate.TemplateException: loader constraint violation: when resolving method "scala.tools.nsc.Settings.(Lscala/Function1;)V" the class loader (instance of sbt/jetty/LazyJettyRun7$SbtWebAppLoader$1) of the current class, org/fusesource/scalate/support/ScalaCompiler, and the class loader (instance of java/net/URLClassLoader) for resolved class, scala/tools/nsc/Settings, have different Class objects for the type scala/Function1 used in the signature
    at org.fusesource.scalate.TemplateEngine.compileAndLoad(TemplateEngine.scala:775)
    at org.fusesource.scalate.TemplateEngine.compileAndLoadEntry(TemplateEngine.scala:637)
    at org.fusesource.scalate.TemplateEngine.liftedTree1$1(TemplateEngine.scala:368)
    at org.fusesource.scalate.TemplateEngine.load(TemplateEngine.scala:362)
    at org.fusesource.scalate.TemplateEngine.load(TemplateEngine.scala:420)
    at org.fusesource.scalate.TemplateEngine.layout(TemplateEngine.scala:521)
    at com.ford.testbuilder.web.AppDefaults$class.com$ford$testbuilder$web$AppDefaults$$render(SharedTraits.scala:79)
    at com.ford.testbuilder.web.AppDefaults$$anonfun$6.apply(SharedTraits.scala:52)
    at org.scalatra.ScalatraKernel$$anonfun$handle$1$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2$$anonfun$6.apply(ScalatraKernel.scala:133)
    at org.scalatra.ScalatraKernel$$anonfun$handle$1$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2$$anonfun$6.apply(ScalatraKernel.scala:133)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:44)
    at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:42)
    at org.scalatra.ScalatraKernel$$anonfun$handle$1$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2.apply$mcV$sp(ScalatraKernel.scala:133)
    at org.scalatra.ScalatraKernel$$anonfun$handle$1$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2.apply(ScalatraKernel.scala:121)
    at org.scalatra.ScalatraKernel$$anonfun$handle$1$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2.apply(ScalatraKernel.scala:121)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:71)
    at org.scalatra.ScalatraKernel$$anonfun$handle$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(ScalatraKernel.scala:121)
    at org.scalatra.ScalatraKernel$$anonfun$handle$1$$anonfun$apply$mcV$sp$1.apply(ScalatraKernel.scala:121)
    at org.scalatra.ScalatraKernel$$anonfun$handle$1$$anonfun$apply$mcV$sp$1.apply(ScalatraKernel.scala:121)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:71)
    at org.scalatra.ScalatraKernel$$anonfun$handle$1.apply$mcV$sp(ScalatraKernel.scala:120)
    at org.scalatra.ScalatraKernel$$anonfun$handle$1.apply(ScalatraKernel.scala:120)
    at org.scalatra.ScalatraKernel$$anonfun$handle$1.apply(ScalatraKernel.scala:120)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:71)
    at org.scalatra.ScalatraKernel$class.handle(ScalatraKernel.scala:119)
    at com.ford.testbuilder.web.LoginServlet.org$scalatra$CookieSupport$$super$handle(LoginServlet.scala:10)
    at org.scalatra.CookieSupport$$anonfun$handle$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(CookieSupport.scala:102)
    at org.scalatra.CookieSupport$$anonfun$handle$1$$anonfun$apply$mcV$sp$1.apply(CookieSupport.scala:102)
    at org.scalatra.CookieSupport$$anonfun$handle$1$$anonfun$apply$mcV$sp$1.apply(CookieSupport.scala:102)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:71)
    at org.scalatra.CookieSupport$$anonfun$handle$1.apply$mcV$sp(CookieSupport.scala:101)
    at org.scalatra.CookieSupport$$anonfun$handle$1.apply(CookieSupport.scala:101)
    at org.scalatra.CookieSupport$$anonfun$handle$1.apply(CookieSupport.scala:101)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:71)
    at org.scalatra.CookieSupport$class.handle(CookieSupport.scala:100)
    at com.ford.testbuilder.web.LoginServlet.org$scalatra$FlashMapSupport$$super$handle(LoginServlet.scala:10)
    at org.scalatra.FlashMapSupport$$anonfun$handle$1.apply$mcV$sp(flashMap.scala:101)
    at org.scalatra.FlashMapSupport$$anonfun$handle$1.apply(flashMap.scala:100)
    at org.scalatra.FlashMapSupport$$anonfun$handle$1.apply(flashMap.scala:100)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:71)
    at org.scalatra.FlashMapSupport$class.handle(flashMap.scala:100)

1 个答案:

答案 0 :(得分:1)

我在别人的机器上进行了新的结账(工作正常)并比较了类路径,我想到了这一点。我发现我的类路径中有scala-library-2.8.1.jar和scala-library.jar。

这是由我的项目文件中的以下行引起的:

override def filterScalaJars = false

浪费了一天中最好的一部分:(