2

I'm getting this exception when running the scalatra specs2 example from the scalatra docs:

ThrowableException: org.eclipse.jetty.http.HttpGenerator.flushBuffer()I (FutureTask.java:138)

Here is the test code (starting on line 5, skipping imports):

class MyAppTest extends MutableScalatraSpec {
  addServlet(classOf[MyApp], "/*") 

  "GET / on AdminApp" should {
    "return status 200" in {
      get("/") { 
        status must_== 200
      }
    }
  }
}

Here is the app definition:

class MyApp extends ScalatraServlet {

  get("/") {
    "aloha"
  }
}

I'm using scalatra-specs2 2.0.4 and scala 2.9.1. I'm running an embedded jetty server using xsbt-web-plugin 0.2.10 with sbt 0.11.2. The test was executed using sbt test.

Here is the full trace:

[info] GET / on AdminApp should
[error] ! Fragment evaluation error
[error]     ThrowableException: org.eclipse.jetty.http.HttpGenerator.flushBuffer()I (FutureTask.java:138)
[error] org.eclipse.jetty.testing.HttpTester.generate(HttpTester.java:225)
[error] org.scalatra.test.ScalatraTests$class.submit(ScalatraTests.scala:46)
[error] com.example.MyAppTest.submit(MyAppTest.scala:5)
[error] org.scalatra.test.ScalatraTests$class.submit(ScalatraTests.scala:71)
[error] com.example.MyAppTest.submit(MyAppTest.scala:5)
[error] org.scalatra.test.ScalatraTests$class.get(ScalatraTests.scala:127)
[error] com.example.MyAppTest.get(MyAppTest.scala:5)
[error] com.example.MyAppTest$$anonfun$1$$anonfun$apply$3.apply(MyAppTest.scala:10)
[error] com.example.MyAppTest$$anonfun$1$$anonfun$apply$3.apply(MyAppTest.scala:10)
[error] org.eclipse.jetty.http.HttpGenerator.flushBuffer()I
[error] org.eclipse.jetty.testing.HttpTester.generate(HttpTester.java:225)
[error] org.scalatra.test.ScalatraTests$class.submit(ScalatraTests.scala:46)
[error] com.example.MyAppTest.submit(MyAppTest.scala:5)
[error] org.scalatra.test.ScalatraTests$class.submit(ScalatraTests.scala:71)
[error] com.example.MyAppTest.submit(MyAppTest.scala:5)
[error] org.scalatra.test.ScalatraTests$class.get(ScalatraTests.scala:127)
[error] com.example.MyAppTest.get(MyAppTest.scala:5)
[error] com.example.MyAppTest$$anonfun$1$$anonfun$apply$3.apply(MyAppTest.scala:10)
[error] com.example.MyAppTest$$anonfun$1$$anonfun$apply$3.apply(MyAppTest.scala:10)

This is the only search result that has turned up so far: Fragment Evaluation Error.

Can someone point me in the right direction?

Thanks, -f

4

2 回答 2

1

仍然不确定根本原因,但在将 jetty-webapp 从 8.0.3.v20111011 滚动回 7.6.0.v20120127 后,测试成功执行。

于 2012-05-11T18:57:42.320 回答
0

您的依赖项可能存在冲突,更具体地说是 Jetty 库版本。由于 Jetty 6 和 Jetty 7 之间的“flush”方法HttpGenerator发生了变化,您可能会收到“NoSuchMethodFoundError”,它解释了异常消息中奇怪的“org.eclipse.jetty.http.HttpGenerator.flushBuffer()I”签名。

这也解释了为什么您会收到“片段评估错误”,而不是您提到的链接中解释的常规故障。

如果您尝试使用最新的 specs2-1.10-SNAPSHOT,当发生这种情况时,您将收到一条更好的“片段评估错误”消息,显示“NoSuchMethodError”。这将帮助您更快地诊断问题。

于 2012-05-10T23:03:09.000 回答