我正面临着一个奇怪的问题与萨拉特和这种情况下,尤其是当我运行我的发挥网络应用程序。
这是StackTrace:

Caused by: java.util.concurrent.ExecutionException: Boxed Error
at scala.concurrent.impl.Promise$.resolver(Promise.scala:52) ~[scala-library.jar:na]
at scala.concurrent.impl.Promise$.scala$concurrent$impl$Promise$$resolveTry(Promise.scala:44) ~[scala-library.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:116) [scala-library.jar:na]
... 9 common frames omitted

原因:com.novus.salat.util.graterglitch:
  GRATER GLITCH - unable to find or instantiate a grater using supplied path name

  REASON: Very strange!  Path='domain.content.Exam' from pickled ScalaSig causes ClassNotFoundException

  Context: 'global'
  Path from pickled Scala sig: 'domain.content.Exam'



at com.novus.salat.Context$class.lookup(Context.scala:213) ~[salat-core_2.10-1.9.2.jar:1.9.2]
at com.novus.salat.global.package$$anon$1.lookup(global.scala:29) ~[salat-core_2.10-1.9.2.jar:1.9.2]
at com.novus.salat.package$.grater(package.scala:62) ~[salat-core_2.10-1.9.2.jar:1.9.2]
at com.novus.salat.dao.SalatDAO.<init>(SalatDAO.scala:48) ~[salat-core_2.10-1.9.2.jar:1.9.2]
at domain.content.ExamDAO$.<init>(Exam.scala:31) ~[classes/:na]
at domain.content.ExamDAO$.<clinit>(Exam.scala) ~[classes/:na]
at domain.content.Exam$.getAllExamsForTechnology(Exam.scala:22) ~[classes/:na]
at core.ContentService.allExamsForTechnology(ContentService.scala:30) ~[classes/:na]
at controllers.content.ExamController$$anonfun$allExamsForTechnology$1.apply(ExamController.scala:24) ~[classes/:na]
at controllers.content.ExamController$$anonfun$allExamsForTechnology$1.apply(ExamController.scala:22) ~[classes/:na]
at play.api.mvc.ActionBuilder$$anonfun$apply$10.apply(Action.scala:221) ~[play_2.10.jar:2.2.1]
at play.api.mvc.ActionBuilder$$anonfun$apply$10.apply(Action.scala:220) ~[play_2.10.jar:2.2.1]
at play.api.mvc.Action$.invokeBlock(Action.scala:357) ~[play_2.10.jar:2.2.1]
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:309) ~[play_2.10.jar:2.2.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:109) ~[play_2.10.jar:2.2.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:109) ~[play_2.10.jar:2.2.1]
at play.utils.Threads$.withContextClassLoader(Threads.scala:18) ~[play_2.10.jar:2.2.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:108) ~[play_2.10.jar:2.2.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:107) ~[play_2.10.jar:2.2.1]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:107) ~[play_2.10.jar:2.2.1]
at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:100) ~[play_2.10.jar:2.2.1]
at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:481) ~[play-iteratees_2.10.jar:2.2.1]
at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:481) ~[play-iteratees_2.10.jar:2.2.1]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:517) ~[play-iteratees_2.10.jar:2.2.1]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:517) ~[play-iteratees_2.10.jar:2.2.1]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$13.apply(Iteratee.scala:493) ~[play-iteratees_2.10.jar:2.2.1]
at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$13.apply(Iteratee.scala:493) ~[play-iteratees_2.10.jar:2.2.1]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) [scala-library.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) [scala-library.jar:na]
... 6 common frames omitted

这个奇怪的错误是什么原因?

最佳答案

我添加了一个自定义包对象,如下所示:

import com.novus.salat.Context
import play.api.Play

package object CustomPlaySalatContext {
  implicit val ctx = new Context {
    val name = "Custom_Classloader"
  }
  ctx.registerClassLoader(Play.classloader(Play.current))
}

在dao对象中导入上述包,问题现在就不存在了!

关于mongodb - Salat GRATER GLITCH ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20715277/

10-10 14:37