You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
I have a simple program (inspired by a sample from another blog) that receives data to a POST request at JSON, and works fine when I use the json4s variant. However when I run the same requests into a version of the app that uses the Hakka-http-json I see an unmarshalling exception when unmarshalling a JSON array.
I'd expect equivalent behaviour in both examples, so I suspect something is missing in either my code, documentation, or elsewhere?
Jackson:
$ curl -X POST -H 'Content-Type: application/json' -d '[{"name": "Julie-ann", "age": 21}, {"name": "George", "age": 22}]' http://localhost:8080/customers
There was an internal server error
Server:
[info] Running com.example.JacksonHttpApp
Press RETURN to stop...
[INFO] [08/09/2017 15:54:40.459] [JacksonHttpApp-akka.actor.default-dispatcher-3] [akka.actor.ActorSystemImpl(JacksonHttpApp)] Server online at http://localhost:8080/
[ERROR] [08/09/2017 15:54:44.851] [JacksonHttpApp-akka.actor.default-dispatcher-6] [akka.actor.ActorSystemImpl(JacksonHttpApp)] Error during processing of request: 'scala.collection.immutable.Map$Map2 cannot be cast to com.example.JacksonHttpApp$Customer'. Completing with 500 Internal Server Error response. To change default exception handling behavior, provide a custom ExceptionHandler.
java.lang.ClassCastException: scala.collection.immutable.Map$Map2 cannot be cast to com.example.JacksonHttpApp$Customer
at scala.collection.immutable.List.foreach(List.scala:389)
at com.example.JacksonHttpApp$.$anonfun$routes$4(AkkaJacksonParsing.scala:27)
at akka.http.scaladsl.server.directives.RouteDirectives.$anonfun$complete$1(RouteDirectives.scala:47)
...
I have a simple program (inspired by a sample from another blog) that receives data to a POST request at JSON, and works fine when I use the json4s variant. However when I run the same requests into a version of the app that uses the Hakka-http-json I see an unmarshalling exception when unmarshalling a JSON array.
I'd expect equivalent behaviour in both examples, so I suspect something is missing in either my code, documentation, or elsewhere?
Json4s:
$ curl -X POST -H 'Content-Type: application/json' -d '[{"name": "Julie-ann", "age": 21}, {"name": "George", "age": 22}]' http://localhost:8080/customers
"Added 2 customers\n
$ curl http://localhost:8080/customers
[{"name":"Julie-ann","age":21},{"name":"George","age":22}]
Jackson:
$ curl -X POST -H 'Content-Type: application/json' -d '[{"name": "Julie-ann", "age": 21}, {"name": "George", "age": 22}]' http://localhost:8080/customers
There was an internal server error
Server:
[info] Running com.example.JacksonHttpApp
Press RETURN to stop...
[INFO] [08/09/2017 15:54:40.459] [JacksonHttpApp-akka.actor.default-dispatcher-3] [akka.actor.ActorSystemImpl(JacksonHttpApp)] Server online at http://localhost:8080/
[ERROR] [08/09/2017 15:54:44.851] [JacksonHttpApp-akka.actor.default-dispatcher-6] [akka.actor.ActorSystemImpl(JacksonHttpApp)] Error during processing of request: 'scala.collection.immutable.Map$Map2 cannot be cast to com.example.JacksonHttpApp$Customer'. Completing with 500 Internal Server Error response. To change default exception handling behavior, provide a custom ExceptionHandler.
java.lang.ClassCastException: scala.collection.immutable.Map$Map2 cannot be cast to com.example.JacksonHttpApp$Customer
at scala.collection.immutable.List.foreach(List.scala:389)
at com.example.JacksonHttpApp$.$anonfun$routes$4(AkkaJacksonParsing.scala:27)
at akka.http.scaladsl.server.directives.RouteDirectives.$anonfun$complete$1(RouteDirectives.scala:47)
...
Progs attached here...
progs.zip
The text was updated successfully, but these errors were encountered: