scalaplayframeworkreactivemongoplay-reactivemongo

ReactiveMongoModule cannot be instantiated


Not sure what is happening, everything compiles fine, but when I run the project it fails. I have imported reactivemongo in build.sbt and I have the below enabled in my application.conf file. I am using play 2.5.10

play.modules.enabled += "play.modules.reactivemongo.ReactiveMongoModule"

This is the error:

Module [play.modules.reactivemongo.ReactiveMongoModule] cannot be instantiated.

java.lang.ClassNotFoundException: play.modules.reactivemongo.ReactiveMongoModule
 java.net.URLClassLoader.findClass(URLClassLoader.java:381)
 java.lang.ClassLoader.loadClass(ClassLoader.java:424)
 java.lang.ClassLoader.loadClass(ClassLoader.java:357)
 play.api.inject.Modules$$anonfun$locate$1$$anonfun$apply$1.apply(Module.scala:115)
 play.api.inject.Modules$$anonfun$locate$1$$anonfun$apply$1.apply(Module.scala:115)
 play.api.inject.Modules$.play$api$inject$Modules$$constructModule(Module.scala:121)
 play.api.inject.Modules$$anonfun$locate$1.apply(Module.scala:114)
 play.api.inject.Modules$$anonfun$locate$1.apply(Module.scala:113)
 scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
 scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
 scala.collection.immutable.HashSet$HashSet1.foreach(HashSet.scala:322)
 scala.collection.immutable.HashSet$HashTrieSet.foreach(HashSet.scala:978)
 scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
 scala.collection.AbstractSet.scala$collection$SetLike$$super$map(Set.scala:47)
 scala.collection.SetLike$class.map(SetLike.scala:92)
 scala.collection.AbstractSet.map(Set.scala:47)
 play.api.inject.Modules$.locate(Module.scala:113)
 play.api.inject.guice.GuiceableModule$.loadModules(GuiceInjectorBuilder.scala:272)
 play.api.inject.guice.GuiceApplicationBuilder$$anonfun$$lessinit$greater$default$10$1.apply(GuiceApplicationBuilder.scala:30)
 play.api.inject.guice.GuiceApplicationBuilder$$anonfun$$lessinit$greater$default$10$1.apply(GuiceApplicationBuilder.scala:30)
 play.api.inject.guice.GuiceApplicationBuilder.applicationModule(GuiceApplicationBuilder.scala:109)
 play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
 play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
 play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
 play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:168)
 play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:164)
 play.utils.Threads$.withContextClassLoader(Threads.scala:21)
 play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:164)
 play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:131)
 scala.Option.map(Option.scala:146)
 play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:131)
 play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:129)
 scala.util.Success.flatMap(Try.scala:231)
 play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:129)
 play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:121)
 scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
 scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
 java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
 java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
 java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
 java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
 java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Solution

  • Possible issue: you add the reactive mongo itself but not the reactive mongo play module. Check the build.sbt, it must looks like:

    libraryDependencies += "org.reactivemongo" %% "play2-reactivemongo" % "0.12.0"