java.lang.ClassNotFoundException: reactivemongo.api.MongoDriver

25 views
Skip to first unread message

Andrei Biketov

unread,
Sep 22, 2017, 8:47:53 PM9/22/17
to ReactiveMongo - http://reactivemongo.org
Hi,

I'm getting the following error:

java.lang.NoClassDefFoundError: reactivemongo/api/MongoDriver
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: reactivemongo.api.MongoDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" 

Environment: sbt 1.0.2 & scala 2.12

build.sbt dependencies:

libraryDependencies += "com.typesafe.play" % "play-json_2.12" % "2.6.3"
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.12" % "2.5.4"
libraryDependencies += "com.typesafe.akka" % "akka-testkit_2.12" % "2.5.4" % "test"
libraryDependencies += "org.reactivemongo" % "reactivemongo_2.12" % "0.12.6" % "provided"
libraryDependencies += "org.reactivemongo" % "reactivemongo-bson_2.12" % "0.12.6"
libraryDependencies += "org.reactivemongo" % "reactivemongo-bson-macros_2.12" % "0.12.6"
libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.25"

Works with version 2.11

Andrei Biketov

unread,
Sep 22, 2017, 8:53:15 PM9/22/17
to ReactiveMongo - http://reactivemongo.org
Solved: 
libraryDependencies += "org.reactivemongo" % "reactivemongo_2.12" % "0.12.6" % "provided"
"provided" must be removed. Just copied it from maven as is. Not sure why they put it at the end.

Cédric Chantepie

unread,
Sep 23, 2017, 7:49:50 AM9/23/17
to ReactiveMongo - http://reactivemongo.org
Having the scala dependencies defined with _2.12 (fixed version) is error prone and prevent cross build.

Moreover, if the dependency for the driver is specified, the bson and bson macros dependencies should not be explicitly added, as it can cause versions conflict.

Reply all
Reply to author
Forward
0 new messages