Search code examples
scalamavenunit-testingcassandrascalatest

Unable to start instance of StubbedCassandra in Scala


I am trying to start an instance of StubbedCassandra in Scala with Maven and ScalaTest, based on the documentation found here: http://scassandra-docs.readthedocs.io/en/latest/java/overview/

val scassandra = ScassandraFactory.createServer()
scassandra.start()

This is the dependency that I have in my Pom.xml file:

<dependency>
    <groupId>org.scassandra</groupId>
    <artifactId>java-client</artifactId>
    <version>1.1.1</version>
</dependency>

and I have tried with the standalone version as well:

<dependency>
    <groupId>org.scassandra</groupId>
    <artifactId>java-client</artifactId>
    <version>1.1.1</version>
    <classifier>standalone</classifier>
    <scope>test</scope>
</dependency>

But when I try to run it with Maven, it throws this error even after a 'mvn clean test':

*** RUN ABORTED ***
  java.lang.RuntimeException: Unable to load a Suite class that was discovered in the runpath: com.neruti.ml.test.ReadTest
  at org.scalatest.tools.DiscoverySuite$.getSuiteInstance(DiscoverySuite.scala:84)
  at org.scalatest.tools.DiscoverySuite$$anonfun$1.apply(DiscoverySuite.scala:38)
  at org.scalatest.tools.DiscoverySuite$$anonfun$1.apply(DiscoverySuite.scala:37)
  at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
  at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
  at scala.collection.Iterator$class.foreach(Iterator.scala:893)
  at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
  at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
  at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
  at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
  ...
  Cause: akka.ConfigurationException: Could not start logger due to [akka.ConfigurationException: Logger specified in config can't be loaded [akka.event.slf4j.Slf4jLogger] due to [akka.ConfigurationException: configuration problem while creating [akka://Scassandra/system/log1-Slf4jLogger] with dispatcher [akka.actor.default-dispatcher] and mailbox [akka.actor.default-mailbox]]]
  at akka.event.LoggingBus$class.startDefaultLoggers(Logging.scala:144)
  at akka.event.EventStream.startDefaultLoggers(EventStream.scala:26)
  at akka.actor.LocalActorRefProvider.init(ActorRefProvider.scala:623)
  at akka.actor.ActorSystemImpl.liftedTree2$1(ActorSystem.scala:620)
  at akka.actor.ActorSystemImpl._start$lzycompute(ActorSystem.scala:617)
  at akka.actor.ActorSystemImpl._start(ActorSystem.scala:617)
  at akka.actor.ActorSystemImpl.start(ActorSystem.scala:634)
  at akka.actor.ActorSystem$.apply(ActorSystem.scala:142)
  at akka.actor.ActorSystem$.apply(ActorSystem.scala:109)
  at scassandra.org.scassandra.server.ServerStubRunner$.actorSystem$lzycompute(ServerStubRunner.scala:43)

Solution

  • Nevermind, just needed to include this dependency into the pom.xml file:

    <dependency>
        <groupId>org.scassandra</groupId>
        <artifactId>scassandra-server_2.11</artifactId>
        <version>1.1.1</version>
    </dependency>