reactivecouchbase-rs-core
reactivecouchbase-rs-core copied to clipboard
Runtime exception running ViewQuery: JsonDocument cannot be cast to RawJsonDocument
I'm trying to migrate a productive Scala Play server application using reactivecouchbase-play to the latest play version (2.6.9) and reactivecouchbase-rs-core (1.2.2-SNAPSHOT).
The application compiles and succeeds to connect to couchbase server (5.0.1), but now I hit a runtime exception inside the reactivecouchbase-rs-core code (query.scala:57) when the following ViewQuery is executed:
bucket.searchView[MyType](ViewQuery(designDocumentName, userViewName, _.includeDocs().stale(Stale.FALSE))).flatMap(viewRow => Source.fromFuture(viewRow.typed)).asSeq
Exception:
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[ClassCastException: com.couchbase.client.java.document.JsonDocument cannot be cast to com.couchbase.client.java.document.RawJsonDocument]] at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:255) at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:180) at play.core.server.AkkaHttpServer$$anonfun$12$$anonfun$apply$1.applyOrElse(AkkaHttpServer.scala:252) at play.core.server.AkkaHttpServer$$anonfun$12$$anonfun$apply$1.applyOrElse(AkkaHttpServer.scala:251) at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:344) at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:343) at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) at play.api.libs.streams.Execution$trampoline$.executeScheduled(Execution.scala:109) at play.api.libs.streams.Execution$trampoline$.execute(Execution.scala:71) at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40) Caused by: java.lang.ClassCastException: com.couchbase.client.java.document.JsonDocument cannot be cast to com.couchbase.client.java.document.RawJsonDocument at org.reactivecouchbase.rs.scaladsl.ViewRow$$anonfun$doc$3.apply(query.scala:57) at scala.concurrent.Future$$anonfun$filter$1.apply(Future.scala:278) 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) at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235) at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
I have a play.api.libs.json.Fomat for my type "implicit val myTypeFormat: Format[MyType]" (which worked perfectly with the reactivecouchbase-play plugin) that I now convert to org.reactivecouchbase.rs.scaladsl.JsonFormat using "implicit val myTypeJsonFormat = convertJsonFormat(myTypeFormat)".
The api call using the same type works without problems:
bucket.get[MyType](key)
Thank you for checking that.