[info] akka.actor.ActorInitializationException: You cannot create an instance of [reactivemongo.core.actors.StandardDBSystem] explicitly using the constructor (new). You have to use one of the 'actorOf' factory methods to create a new actor. See the documentation.
[info] at reactivemongo.api.MongoConnection.database(api.scala)
[info] at akka.actor.ActorInitializationException$.apply(Actor.scala:167)
[info] at akka.actor.Actor$class.$init$(Actor.scala:423)
[info] at reactivemongo.core.actors.StandardDBSystem.<init>(actors.scala:1240)
[info] at reactivemongo.api.MongoDriver.dbsystem$lzycompute$1(api.scala:960)
[info] at reactivemongo.api.MongoDriver.reactivemongo$api$MongoDriver$$dbsystem$1(api.scala:955)
[info] at reactivemongo.api.MongoDriver$$anonfun$connection$2$$anonfun$apply$29.apply(api.scala:976)
[info] at reactivemongo.api.MongoDriver$$anonfun$connection$2$$anonfun$apply$29.apply(api.scala:976)
[info] at reactivemongo.api.MongoConnection$$anonfun$probe$1$$anonfun$apply$22.apply(api.scala:503)
[info] at reactivemongo.api.MongoConnection$$anonfun$probe$1$$anonfun$apply$22.apply(api.scala:496)
class MongoDatabase(uri: String) extends ExecutionContextProvider {
private val parsedUri = MongoConnection.parseURI(uri).getOrElse(sys.error(s"Database not configured!"))
private val driver: MongoDriver = new MongoDriver()
private val connection = driver.connection(parsedUri)
def database: Future[DefaultDB] = connection.database(parsedUri.db.getOrElse(sys.error(s"Database not specified in uri`")))
override implicit val executionContext: ExecutionContext = connection.actorSystem.dispatcher
def close(): Unit = driver.close(10.seconds)
}
Await.result(connection.mapTo[MongoConnection].map { c =>
// TODO: Review
c.history = () => dbsystem.internalState
c
}, Duration.Inf)
This code actually violates some akka principles, because it is:
You can find more information here: https://groups.google.com/forum/#!topic/akka-user/L3wV_9hm-hQ
MongoDatabase
, only one `MongoConnection` is created. But each sbt module has it's own embedded mongo database with own `MongoDriver` and `MongoConnection` is tests. So from `MongoDriver` perspective only one `MongoConnection` is created.