Search code examples
scalacasbahsalat

Casbah Scala Runtime Error


I have a Play framework based webapp which has the following defined in its build.sbt file:

....
version := "1.0-SNAPSHOT"

resolvers += "Sonatype Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"

resolvers += "Sonatype Releases"  at "https://oss.sonatype.org/content/groups/scala-tools"

resolvers += "Novus Releases" at "http://repo.novus.com/releases/"

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  "com.mongodb.casbah" % "casbah_2.9.0" % "2.2.0-SNAPSHOT",
  "com.novus" %% "salat-core" % "1.9.2",
  "org.scalatest" % "scalatest_2.10" % "2.0" % "test",
  "com.typesafe" %  "config" % "1.0.2"
)
....

The Scala version is 2.10.3 and when I try to run a unit test, I run into the following error:

A needed class was not found. This could be due to an error in your runpath. Missing class: scala/reflect/ClassManifest
java.lang.NoClassDefFoundError: scala/reflect/ClassManifest
    at com.mongodb.casbah.Imports$.<init>(Implicits.scala:113)
    at com.mongodb.casbah.Imports$.<clinit>(Implicits.scala)
    at com.mongodb.casbah.MongoConnection.apply(MongoConnection.scala:177)
        ........
        ........

I'm completely clueless as to why this is happening? Which additional library is that I'm missing?


Solution

  • You can't mix major scala versions (see, casbah artifact is compiled against scala 2.9.*, whereas scala_test is for 2.10.*, and you're saying you use 2.10 in intellij).

    The error says, that compiler can't find class that was cut out from scala library since 2.9.* times and solution is to pick proper scala version (any 2.10.* will fit).