Why in runtime the app have java.lang.NoClassDefFoundError: reactivemongo/api/bson/SafeBSONWriter

75 Views Asked by At

I have a simple service as an example:

object SimpleService {

  def findById(id: String, col: MongoCollections): Future[Option[Simple]] =
    collection(col).flatMap(c => c.find(selectorId(id)).one[Simple])

}

where the Simple:

case class Simple(@Key("_id")id: String, name: String,)

object Simple{
 implicit val eventHandler: BSONDocumentHandler[Simple] = 
   Macros.using[MacroOptions.ReadDefaultValues].handler[Simple]
}

Then I have written some integration tests and everything works fine when I run the tests. I can do all CRUD operations in the tests.

But I added a server with some simple API and when I use a method findById from SimpleService

I have an error in runtime only:

Uncaught error from thread [SimpleServer-akka.actor.default-dispatcher-5]: reactivemongo/api/bson/SafeBSONWriter, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[SomeServer]
java.lang.NoClassDefFoundError: reactivemongo/api/bson/SafeBSONWriter

FYI: SafeBSONWriter is a private trait and object in the library.

Could you suggest where to look?

1

There are 1 best solutions below

0
Iyappan Sankaran On

Add the "reactivemongo-bson-api" dependency, this will solve the issue