Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime exception running ViewQuery: JsonDocument cannot be cast to RawJsonDocument #27

Open
mtidei opened this issue Apr 15, 2018 · 1 comment

Comments

@mtidei
Copy link

mtidei commented Apr 15, 2018

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.

@mathieuancelin
Copy link
Member

@mtidei can you provide me a full test case (with the view source, example documents, the search, etc ...) so I can include it in the next release ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants