Spray Client中的ClassCastException

时间:2015-08-03 19:01:34

标签: scala akka spray spray-json spray-client

获取以下错误 -

java.lang.ClassCastException: Cannot cast akka.io.Tcp$ErrorClosed to spray.http.HttpResponse
    at java.lang.Class.cast(Class.java:3369) ~[na:1.8.0_45]
    at scala.concurrent.Future$$anonfun$mapTo$1.apply(Future.scala:405) 
    at scala.util.Success$$anonfun$map$1.apply(Try.scala:236) 
    at scala.util.Try$.apply(Try.scala:191) 
    at scala.util.Success.map(Try.scala:236) 
    at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235) 

以下是我正在尝试的代码:

 val response = HttpDialog(Http.connect("URL",port,false)
       .send(Get(String.format(endpoint, message)))
       .end

val result = Await.result(response, DEFAULT_TIMEOUT)


val myResponse = try {
 Left(JsonParser(result.message.entity.asString).convertTo[MyResponse])
      } catch {
        case ex: Exception =>
        log.error("Error converting message payload: ", ex)
        Right(ex)
      }

为什么会出现这个错误,我尝试搜索但找不到相关内容。

以下是我正在使用的版本

"io.spray"%%"spray-can"% "1.3.2",
"io.spray"%%"spray-routing"% "1.3.2",
"io.spray"%%"spray-testkit"% "1.3.2"% "test",
"io.spray"%%"spray-client"% "1.3.2",
"io.spray"%%"spray-json"% "1.2.6",
"com.typesafe.akka"%%"akka-actor"% "2.3.6",
"com.typesafe.akka"%%"akka-cluster"% "2.3.6",
"com.typesafe.akka"%%"akka-contrib"% "2.3.6",
"com.typesafe.akka"%%"akka-slf4j"% "2.3.6"

0 个答案:

没有答案