Search code examples
mongodbscalacasbah

Casbah MongoDB driver compiler error


I'm using the Casbah driver for MongoDB and while I compiled my project, it fails with the following error:

[INFO] Compiling 12 source files to /core/target/classes at 1394903201140
[ERROR] error: bad symbolic reference. A signature in MongoClient.class refers to type MongoClientURI
[INFO] in package com.mongodb which is not available.
[INFO] It may be completely missing from the current classpath, or the version on
[INFO] the classpath might be incompatible with the version used when compiling MongoClient.class.
[ERROR] error: bad symbolic reference. A signature in MongoClient.class refers to type MongoClient
[INFO] in package com.mongodb which is not available.
[INFO] It may be completely missing from the current classpath, or the version on
[INFO] the classpath might be incompatible with the version used when compiling MongoClient.class.
[ERROR] two errors found

I'm having the following setup as my maven dependency:

<dependency>
  <groupId>org.mongodb</groupId>
  <artifactId>casbah_2.10</artifactId>
  <version>2.7.0-RC2</version>
</dependency>

Why would it now fail during compilation? Any clues what to look for or what to change? Additionally, I also see the following warnings:

[WARNING]  Expected all dependencies to require Scala version: 2.10.3
[WARNING]  org.mongodb:casbah_2.10:2.7.0-RC2 requires scala version: 2.10.3
[WARNING]  org.mongodb:casbah-commons_2.10:2.7.0-RC2 requires scala version: 2.10.3
[WARNING]  com.github.nscala-time:nscala-time_2.10:0.6.0 requires scala version: 2.10.2

Has this got any relation to the compilation failure? Additionally, I ran maven in debug mode and this is what I see in my classpath:

[DEBUG] Classpath: [/../../target/classes
 /Softwares/maven-repo/org/scala-lang/scala-library/2.10.3/scala-library-2.10.3.jar
 /Softwares/maven-repo/org/mongodb/casbah-commons_2.10/2.7.0-RC2/casbah-commons_2.10-2.7.0-RC2.jar
 /Softwares/maven-repo/com/github/nscala-time/nscala-time_2.10/0.6.0/nscala-time_2.10-0.6.0.jar
 /Softwares/maven-repo/org/joda/joda-convert/1.2/joda-convert-1.2.jar
 /Softwares/maven-repo/org/slf4j/slf4j-api/1.6.0/slf4j-api-1.6.0.jar
 /Softwares/maven-repo/org/mongodb/casbah-core_2.10/2.7.0-RC2/casbah-core_2.10-2.7.0-RC2.jar
 /Softwares/maven-repo/org/mongodb/casbah-query_2.10/2.7.0-RC2/casbah-query_2.10-2.7.0-RC2.jar
 /Softwares/maven-repo/org/mongodb/casbah-gridfs_2.10/2.7.0-RC2/casbah-gridfs_2.10-2.7.0-RC2.jar
 /Softwares/maven-repo/com/novus/salat-core_2.9.2/0.0.8/salat-core_2.9.2-0.0.8.jar
 /Softwares/maven-repo/com/novus/salat-util_2.9.2/0.0.8/salat-util_2.9.2-0.0.8.jar
 /Softwares/maven-repo/org/scala-lang/scalap/2.9.2/scalap-2.9.2.jar
 /Softwares/maven-repo/org/scala-lang/scala-compiler/2.9.2/scala-compiler-2.9.2.jar
 /Softwares/maven-repo/org/mongodb/mongo-java-driver/2.7.3/mongo-java-driver-2.7.3.jar
 /Softwares/maven-repo/com/mongodb/casbah/casbah-core_2.9.1/2.1.5-1/casbah-core_2.9.1-2.1.5-1.jar
 /Softwares/maven-repo/com/mongodb/casbah/casbah-commons_2.9.1/2.1.5-1/casbah-commons_2.9.1-2.1.5-1.jar
 /Softwares/maven-repo/org/scala-tools/time/time_2.9.1/0.5/time_2.9.1-0.5.jar
 /Softwares/maven-repo/org/scalaj/scalaj-collection_2.9.1/1.2/scalaj-collection_2.9.1-1.2.jar
 /Softwares/maven-repo/com/mongodb/casbah/casbah-query_2.9.1/2.1.5-1/casbah-query_2.9.1-2.1.5-1.jar
 /Softwares/maven-repo/net/liftweb/lift-json_2.9.1/2.4/lift-json_2.9.1-2.4.jar
 /Softwares/maven-repo/com/thoughtworks/paranamer/paranamer/2.3/paranamer-2.3.jar
 /Softwares/maven-repo/com/typesafe/config/1.0.2/config-1.0.2.jar
 /Softwares/maven-repo/joda-time/joda-time/2.3/joda-time-2.3.jar]

I do not understand from where did the other dependencies especially the ones like casbah-core_2.9.1, casbah-query_2.9.1 make it to my classpath? I do not have them as my maven dependencies in my pom.xml! It is confusing.


Solution

  • I figured out what the problem is. I had an additional dependency to the salat framework that I do not use nut somehow was added during evaluation. It actually was pulling in those additional jar files into the classpath which actually seems to be the reason for this error!