“org.fusesource.scalate.TemplateException:违反加载器约束”使用 SBT 嵌入 Jetty 和 scalatra/scalate 时
我昨天在 SBT 中使用嵌入式“jetty-run”任务时开始收到此错误。我将代码恢复到以前的版本,但它仍然发生。
请注意,我打包了应用程序并将其部署在实际的码头实例中,但没有收到错误。在向我的项目添加一些依赖项(可能相关也可能不相关)后,我开始收到此错误,但后来删除了它们。
我尝试了“clean”、“clean-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)
I started getting this error yesterday when using the embedded 'jetty-run' task in SBT. I reverted my code to a previous version and it's still happening.
Note that I packaged up the application and deployed it in an actual jetty instance and I don't get the error. I started getting this error after adding some dependencies to my project (may or may not be related), but have since removed them.
I tried 'clean' 'clean-lib' and 'clean-cache' as well as cleaning out my ~/.m2/repository, ~/.ivy2/cache and project/boot directories.
Anybody have any other ideas?
The line that is blowing up is:
templateEngine.layout(uri, Map("flash" -> flash))
More of the stack trace is below:
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在尝试在别人的机器上进行新的检查(工作正常)并比较类路径后,我发现了这一点。我发现我的类路径中既有 scala-library-2.8.1.jar 又有 scala-library.jar 。
这是由我的项目文件中的以下行引起的:
在此浪费了一天的大部分时间:(
I figured this out after trying a fresh checkout on someone else's machine (which was working fine) and comparing the classpaths. I found that I had both the scala-library-2.8.1.jar as well as the scala-library.jar in my classpath.
This was caused by the following line in my project file:
Wasted the better part of a day on this :(