2

I have added casbah to my dependancies using

  <dependency>
  <groupId>com.mongodb.casbah</groupId>
  <artifactId>casbah_2.8.0</artifactId>
  <version>2.1.5.0</version>
  </dependency>

Then i just wrote a simple mongo connection statement

 val mongoConn = MongoConnection()
 val mongoDB = mongoConn("test")
 val newObj = MongoDBObject("foo" -> "bar","x"->"y","pie"->3.14,"spam"->"eggs")

Then i compiled it

mvn compile

But it is throwing errors that it cannot find the goal

[ERROR] Failed to execute goal on project test-project: Could not resolve depend
encies for project org.scala-lang:test-project:jar:default: Could not find artif
act com.mongodb.casbah:casbah_2.8.0:jar:2.1.5.0 in scala-tools.org (http://scala
-tools.org/repo-releases) -> [Help 1]

Can some one tell me what the problem is. I didnt make any other changes to the POM other than adding this dependancy. Truth is i dont know what else to change in it. But i also observed that intellij idea shows auto complete options for casbah objects and classes, all this is so confusing for me.

swordfish
  • 4,899
  • 5
  • 33
  • 61
  • Looks like a Maven problem to me. The equivalent dependency (`libraryDependencies += "com.mongodb.casbah" % "casbah_2.8.0" % "2.1.5.0"`) works fine in sbt. – Seth Tisue Jul 20 '11 at 12:13

3 Answers3

4

Try specifying the below(note the type), replace scala.version with 2.8.0 or which version you are using.

  <dependency>
      <groupId>com.mongodb.casbah</groupId>
      <artifactId>casbah_${scala.version}</artifactId>
      <version>2.1.5-1</version>
      <scope>compile</scope>
      <type>pom</type>
    </dependency>
tommy chheng
  • 9,108
  • 9
  • 55
  • 72
2

I had the same problem and resolved it with splitting whole casbah dependency into list of subdependencies:

<properties>
    <scala.version>2.9.0-1</scala.version>
</properties>
<!--Database : casbah -->
<dependency>
   <groupId>com.mongodb.casbah</groupId>
   <artifactId>casbah-commons_${scala.version}</artifactId>
   <version>2.1.5-1</version>
</dependency>
<dependency>
<groupId>com.mongodb.casbah</groupId>
   <artifactId>casbah-query_${scala.version}</artifactId>
   <version>2.1.5-1</version>
   </dependency>
<dependency>
   <groupId>com.mongodb.casbah</groupId>
   <artifactId>casbah-gridfs_${scala.version}</artifactId>
   <version>2.1.5-1</version>
</dependency>
<dependency>
   <groupId>com.mongodb.casbah</groupId>
   <artifactId>casbah-core_${scala.version}</artifactId>
   <version>2.1.5-1</version>
</dependency>

Don't forget to change scala and casbah versions to respectively 2.8.0 and 2.1.5.0

om-nom-nom
  • 62,329
  • 13
  • 183
  • 228
0

Perhaps this is an incorrect dependency to specify.

If we look at the repository, we see only the pom file for this dependency and no jar. Maybe, you should try specifying casba-core or something similar.

Raghuram
  • 51,854
  • 11
  • 110
  • 122