1

I'm getting the following error when I try to extend SalatDAO or use grater[T].asObject(x):

class file needed by SalatDAO is missing. reference type MongoCollection of com.mongodb.casbah.TypeImports refers to nonexisting symbol.

I've followed the Salat examples but, for some reason, extending SalatDAO and graters asObject do not work for me. I cannot find any reference to this error online.

Here's my code:

import net.trevor.model.DBConnection._
import com.novus.salat._
import com.novus.salat.global._
import com.mongodb.casbah.Imports._
import com.novus.salat.dao.SalatDAO

//error occurs on following line:
object HandleDAO extends SalatDAO[Handle, ObjectId](DBConnection.db("Handles")){

      def getHandleAsDBObject(handle : Handle) : DBObject = 
         grater[Handle].asDBObject(handle)

      def getHandleFromDBObject(dbObject : DBObject) : Handle =
         //error occurs on following line: 
         grater[Handle].asObject(dbObject)  
 }

I'd really appreciate any help or advice on this. I'm new to Scala and Mongodb.

I'm compiling using sbt compile. Here's my build.sbt

name := "handle_engine"

version := "1.0"

scalaVersion := "2.9.1"

scalacOptions += "-deprecation"

fork in run := true


resolvers ++= Seq(
    "twitter-repo" at "http://maven.twttr.com",
    "repo.novus rels" at "http://repo.novus.com/releases/",
    "repo.novus snaps" at "http://repo.novus.com/snapshots/",
    "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
) 


libraryDependencies ++= {
  val liftVersion = "2.4-M5" // Put the current/latest lift version here
  Seq(
    "net.liftweb" %% "lift-webkit" % liftVersion % "compile->default",
    "net.liftweb" %% "lift-mapper" % liftVersion % "compile->default",
    "net.liftweb" %% "lift-amqp" % liftVersion % "compile->default",
    "net.liftweb" %% "lift-mongodb" % liftVersion % "compile->default",
    "net.liftweb" %% "lift-mongodb-record" % liftVersion % "compile->default",
    "net.liftweb" %% "lift-wizard" % liftVersion % "compile->default")
}



libraryDependencies ++= Seq( 
  "org.eclipse.jetty" % "jetty-server" % "8.1.0.RC5", // % "compile,jetty",
  "org.eclipse.jetty" % "jetty-servlet" % "8.1.0.RC5", // % "compile,jetty",
  "org.mongodb" % "mongo-java-driver" % "compile->default",
  "com.rabbitmq" % "amqp-client" % "compile->default",
  "org.mongodb" % "casbah_2.9.0-1" % "3.0.0-M2",
  "com.novus" % "salat-core_2.8.1" % "0.0.7",    //Salat for MongoDB and Casbah
  "org.apache.avro" % "avro" % "1.6.2",
  "com.twitter" % "util-core_2.9.1" % "1.12.8", "com.twitter" % "util-eval_2.9.1" %   "1.12.8",
  "junit" % "junit" % "4.5" % "test->default",
  "javax.servlet" % "servlet-api" % "2.5" % "provided->default",
  "ch.qos.logback" % "logback-classic" % "0.9.26" % "compile->default"
)

seq(webSettings :_*)

libraryDependencies += "org.mortbay.jetty" % "jetty" % "6.1.26" % "test,container"

libraryDependencies += "org.scala-tools.testing" %% "specs" % "1.6.9" % "test"
fin
  • 39
  • 5
  • What is net.trevor.model.DBConnection? And check that com.mongodb.casbah.MongoCollection is in your classpath – Sergey Passichenko Apr 03 '12 at 11:25
  • @SerJ de SuDDeN. Thanks for the help. MongoCollection is on the classpath. **DBConnection.db("Handles")** is the same as **'com.mongodb.casbah.MongoConnection(host, port).getDB(database)("Handles")'** – fin Apr 03 '12 at 11:59
  • How are you compiling this? Are you using an IDE or are you compiling it from the command line. If you are doing it on the command line, can you also post the exact arguments you are using? – Ren Apr 03 '12 at 15:14
  • I'm using sbt compile. I'll post my build.sbt above. – fin Apr 03 '12 at 18:00

1 Answers1

1

It looks like you might be on an older version of Salat. Try changing you version to following:

"com.novus" %% "salat-core" % "0.0.8-SNAPSHOT"

or

"com.novus" % "salat-core_2.9.1" % "0.0.8-SNAPSHOT"

cracked_all
  • 1,331
  • 1
  • 11
  • 26
  • Thanks. I updated my build.sbt to include the line above (tried both) but I'm afraid I'm still getting the same error. My casbah version seems to be up to date. – fin Apr 05 '12 at 09:17
  • Hmm I can't think of anything else for now except that Salat isn't yet available for Casbah 3 build. Can you try using the last stable release for Casbah 2.1.5-1 – cracked_all Apr 06 '12 at 09:58
  • Just to make sure, you did a reload & update after changing the build file? – cracked_all Apr 06 '12 at 10:32
  • I did indeed @cracked_all. I think you're on the right track though. I do think it's an environment thing. I've searched for latest versions for all the other packages but so far no joy. Still getting same error. Thanks for your help. – fin Apr 06 '12 at 18:47
  • Thanks @cracked_all. Your tip about Casbah version was correct. I went back to the last stable release and it worked. – fin Apr 07 '12 at 12:46