【发布时间】:2012-05-18 17:11:49
【问题描述】:
我在运行 scalatra docs 的 scalatra specs2 示例时遇到此异常:
ThrowableException: org.eclipse.jetty.http.HttpGenerator.flushBuffer()I (FutureTask.java:138)
这是测试代码(从第 5 行开始,跳过导入):
class MyAppTest extends MutableScalatraSpec {
addServlet(classOf[MyApp], "/*")
"GET / on AdminApp" should {
"return status 200" in {
get("/") {
status must_== 200
}
}
}
}
这是应用定义:
class MyApp extends ScalatraServlet {
get("/") {
"aloha"
}
}
我正在使用 scalatra-specs2 2.0.4 和 scala 2.9.1。我正在使用带有 sbt 0.11.2 的 xsbt-web-plugin 0.2.10 运行嵌入式码头服务器。使用sbt test 执行测试。
这是完整的跟踪:
[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)
这是迄今为止出现的唯一搜索结果: Fragment Evaluation Error.
有人能指出我正确的方向吗?
谢谢, -f
【问题讨论】:
-
我不确定,但可能是您没有使用正确的 Jetty 库吗?我注意到“flush”方法在 jetty 6 和 jetty 7 之间发生了变化。这可能会导致“找不到方法错误”,这将解释奇怪的“org.eclipse.jetty.http.HttpGenerator.flushBuffer()I”签名异常消息。这也可以解释为什么这是您提到的链接中解释的“片段评估错误”。
-
如果您尝试使用最新的 specs2-1.10-SNAPSHOT,您应该会收到更好的“片段评估错误”消息,当这种情况发生时显示“NoSuchMethodError”。
-
我刚刚将我的 cmets 转换为常规答案。我希望这是正确的:-)
-
谢谢,埃里克。这是码头图书馆。我尝试了 specs2 的 1.10-SNAPSHOT,但它没有显示“NoSuchMethodError”,但在将 jetty-webapp 从 8.0.3.v20111011 滚动回 7.6.0.v20120127 后测试工作正常。感谢您的帮助!