ScalatraServlet with AkkaSupport with GZipSupport

蹲街弑〆低调 提交于 2019-12-13 06:43:48

问题


I'm trying to use Scalatra with AkkaSupport and the newly introduced (2.2.0 RC2) GZipSupport. It fails and I'm trying to figure out if I'm doing something wrong, before I file a bug report. The code is the default Scalatra/Akka example, including the GZipSupport trait:

package com.myapp

import _root_.akka.dispatch._
import _root_.akka.actor._

import org.scalatra._
import org.scalatra.akka.AkkaSupport

class myappServlet extends ScalatraServlet with AkkaSupport with GZipSupport {
  implicit val system = ActorSystem()

  get("/"){
    Future {
      <html><body>Hello Akka</body></html>
    }
  }
}

I'm getting the following stack trace:

[ERROR] [01/08/2013 17:41:42.274] [default-akka.actor.default-dispatcher-2] [akka.dispatch.Dispatcher] STREAM
    java.lang.IllegalStateException: STREAM
at org.eclipse.jetty.server.Response.getWriter(Response.java:699)
at org.scalatra.servlet.RichResponse.writer(RichResponse.scala:80)
at org.scalatra.ScalatraBase$$anonfun$renderPipeline$1.apply(ScalatraBase.scala:301)
at scala.PartialFunction$$anon$3.apply(PartialFunction.scala:97)
at scala.PartialFunction$$anon$3.apply(PartialFunction.scala:96)
at org.scalatra.ScalatraBase$class.loop$1(ScalatraBase.scala:275)
at org.scalatra.ScalatraBase$class.renderResponseBody(ScalatraBase.scala:277)
at org.scalatra.ScalatraServlet.renderResponseBody(ScalatraServlet.scala:50)
at org.scalatra.ScalatraBase$class.renderResponse(ScalatraBase.scala:245)
at com.myapp.myappServlet.org$scalatra$akka$AkkaSupport$$super$renderResponse(triptaoServlet.scala:9)
at org.scalatra.akka.AkkaSupport$$anonfun$renderResponse$1$$anonfun$apply$1.apply(AkkaSupport.scala:61)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57)
at org.scalatra.DynamicScope$class.withResponse(DynamicScope.scala:50)
at org.scalatra.ScalatraServlet.withResponse(ScalatraServlet.scala:50)
at org.scalatra.servlet.AsyncSupport$$anonfun$withinAsyncContext$1.apply(AsyncSupport.scala:25)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57)
at org.scalatra.DynamicScope$class.withRequest(DynamicScope.scala:41)
at org.scalatra.ScalatraServlet.withRequest(ScalatraServlet.scala:50)
at org.scalatra.servlet.AsyncSupport$class.withinAsyncContext(AsyncSupport.scala:24)
at com.myapp.myappServlet.withinAsyncContext(triptaoServlet.scala:9)
at org.scalatra.akka.AkkaSupport$$anonfun$renderResponse$1.apply(AkkaSupport.scala:58)
at org.scalatra.akka.AkkaSupport$$anonfun$renderResponse$1.apply(AkkaSupport.scala:56)
at akka.dispatch.Future$$anonfun$onSuccess$1.apply(Future.scala:484)
at akka.dispatch.Future$$anonfun$onSuccess$1.apply(Future.scala:483)
at akka.dispatch.DefaultPromise.akka$dispatch$DefaultPromise$$notifyCompleted(Future.scala:943)
at akka.dispatch.DefaultPromise$$anonfun$onComplete$1.apply$mcV$sp(Future.scala:937)
at akka.dispatch.Future$$anon$4$$anonfun$run$1.apply$mcV$sp(Future.scala:386)
at akka.dispatch.Future$$anon$4$$anonfun$run$1.apply(Future.scala:378)
at akka.dispatch.Future$$anon$4$$anonfun$run$1.apply(Future.scala:378)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57)
at akka.dispatch.Future$$anon$4.run(Future.scala:378)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:94)
at akka.jsr166y.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1381)
at akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259)
at akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975)
at akka.jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1479)
at akka.jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)

Is this some bug or am I missing something? Thanks in advance!


回答1:


This was a bug that was acknowledged by core Scalatra developers, it was announced as fixed in v2.2.1.



来源:https://stackoverflow.com/questions/14218851/scalatraservlet-with-akkasupport-with-gzipsupport

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!