40

当我运行我的应用程序时,浏览器显示

[ExecutionException: Boxed Error]

它没有说明行号等。

在控制台中,我有以下内容

! @6elaah0c8 - Internal server error, for (GET) [/testlearn] ->

play.api.Application$$anon$1: Execution exception[[ExecutionException: Boxed Error]]
    at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.1]
    at play.api.DefaultApplication.handleError(Application.scala:383) [play_2.10.jar:2.1.1]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$17$$anonfun$apply$24.apply(PlayDefaultUpstreamHandler.scala:326) [play_2.10.jar:2.1.1]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$17$$anonfun$apply$24.apply(PlayDefaultUpstreamHandler.scala:324) [play_2.10.jar:2.1.1]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.1]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.1]
java.util.concurrent.ExecutionException: Boxed Error
    at scala.concurrent.impl.Promise$.resolver(Promise.scala:52) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
    at scala.concurrent.impl.Promise$.scala$concurrent$impl$Promise$$resolveTry(Promise.scala:44) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
    at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:116) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
    at scala.concurrent.Promise$class.complete(Promise.scala:55) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
    at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:58) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:23) [factorie-1.0.0-M4-jar-with-dependencies.jar:na]
Caused by: java.lang.AssertionError: assertion failed
    at scala.Predef$.assert(Predef.scala:165) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
    at cc.factorie.util.TraversableExtras$class.max2ByDouble(TraversableExtras.scala:95) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
    at cc.factorie.package$$anon$2.max2ByDouble(package.scala:148) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
    at cc.factorie.optimize.SampleRankExample.accumulateExampleInto(SampleRank.scala:31) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
    at cc.factorie.optimize.OnlineTrainer$$anonfun$processExamples$3.apply(Trainer.scala:72) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
    at cc.factorie.optimize.OnlineTrainer$$anonfun$processExamples$3.apply(Trainer.scala:63) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
4

2 回答 2

56

“盒装错误”是 Scala 对ErrorFuture. 在 Java 和 Scala 中,类型的子类Error具有致命错误的特殊含义。请参阅异常和错误之间的区别。简而言之,javadoc 说:

Error 是 Throwable 的子类,表示合理的应用程序不应尝试捕获的严重问题。大多数此类错误是异常情况。

Throwable与在 future 中抛出其他s 不同,当Error抛出 的子类时,默认的 Scala 解析器将用消息字符串“Boxed Error”包裹Error在 ajava.util.concurrent.ExecutionException中,并以失败完成您的承诺。

引用期货文档http://docs.scala-lang.org/overviews/core/futures.html wrtError被抛出:

[Error] 在执行失败的异步计算的线程中重新抛出异常。这背后的基本原理是防止传播通常不由客户端代码处理的关键和控制流相关异常,同时通知客户端计算失败的未来。

如果你想对失败做一些特别的事情,Error可以提取抛出的原始文件(但不是以特别适合模式匹配的方式),通过ExecutionException#getCause()

于 2014-07-30T23:20:57.160 回答
3

我不知道那是 a Boxed Error,但根据您的堆栈跟踪,根本问题来自factorielib,来自第max2Double 95 行的方法

从源代码中提取:

/**Returns both the maximum element and the second-to-max element */
  def max2ByDouble(extractor: A => Double): (A, A) = {
    val s1 = t.toSeq
    assert(s1.length > 1)   // <<<== HERE
    var best1 = Double.NegativeInfinity
    ...

看来你Traversable是空的。

于 2013-06-24T07:35:42.883 回答