Search code examples
scalamongodbcasbah

Casbah Scala MongoDB driver - a strange error


I am trying to use Casbah, I get a strange error right in the beginning, on this line:

val mongoDB = MongoConnection("MyDatabase")

the error on MongoConenction says:

class file needed by MongoConnection is missing. reference type MongoOptions of package com.mongodb refers to nonexisting symbol.

I do not know what to do with this. The jars that I have attached to my projects are:

casbah-commons_2.9.1-3.0.0-SNAPSHOT.jar
casbah-core_2.9.1-3.0.0-SNAPSHOT.jar
casbah-gridfs_2.9.1-3.0.0-SNAPSHOT.jar
casbah-query_2.9.1-3.0.0-SNAPSHOT.jar
casbah-util_2.9.1-3.0.0-SNAPSHOT.jar

which looks like a full setup of Casbah and I do not understand what it might be yearning for. So there is the question number one - what do I have to do to resolve this problem?

The question number two is - the Casbah tutorial says that I could import just one thing, and get the mongoConn() method, which is also not truth. The mongoConn() simply does not get found if I follow the instructions. So, how can I acheive that everythong works as in the tutorial?


Solution

  • I don't know the details of your setup, but it seems like you are not referencing the dependencies of the casbah-commons module.

    According to the docs, those are:

    mongo-java-driver, scalaj-collection, scalaj-time, JodaTime, slf4j-api