0

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?

joesan
  • 13,963
  • 27
  • 95
  • 232

3 Answers3

3

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).

om-nom-nom
  • 62,329
  • 13
  • 183
  • 228
  • Should I then backport and use Scala 2.9? How would using ScalaTest 2.10 have any effect on this? I doubt there is a Casbah version for 2.10. I would have a look if it is available. – joesan Dec 19 '13 at 19:35
  • Thanks for the suggestion. I changed the dependency to the Casbah driver to the following: "org.mongodb" % "casbah_2.10" % "2.5.1" and it worked! – joesan Dec 19 '13 at 19:50
0

Salat author here. The solution is to fix your deps. The latest stable release of Salat is 1.9.4, and it depends on Casbah 2.6.4 - both are available for 2.9 and 2.10.

prasinous
  • 798
  • 3
  • 6
  • `"org.mongodb" %% "casbah" % "2.6.4"` and `"com.novus" %% "salat-core" % "1.9.4"` should fix your build file. – Ross Dec 19 '13 at 19:47
  • It did not work! sbt.ResolveException: unresolved dependency: org.mongodb#casbah;2.6.4: not found – joesan Dec 19 '13 at 19:57
0

Instead of using the casbah driver directly for play I have fallen back into using a plugin called play-salat (https://github.com/leon/play-salat).

The one I use at the moment is "se.radley" % "play-plugins-salat_2.10" % "1.3.0" and works well in Play 2.2.

Donovan
  • 213
  • 2
  • 6