1

I'm using spray with casbah and salat. I get this error when I import the casbah imports,

import com.mongodb.casbah.Imports._

object mongodb is not a member of package com

However, sbt compiles successfully w/o any warning. My build.sbt looks

scalaVersion  := "2.10.3"

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

resolvers ++= Seq(
  "spray repo" at "http://repo.spray.io/",
   "Sonatype releases" at "https://oss.sonatype.org/content/repositories/releases"
)

libraryDependencies ++= {
  val akkaV = "2.2.3"
  val sprayV = "1.2.0"
  Seq(
    "io.spray"            %   "spray-can"     % sprayV,
    "io.spray"            %   "spray-routing" % sprayV,
    "io.spray"            %   "spray-testkit" % sprayV  % "test",
    "com.typesafe.akka"   %%  "akka-actor"    % akkaV,
    "com.typesafe.akka"   %%  "akka-testkit"  % akkaV   % "test",
    "org.specs2"          %%  "specs2-core"   % "2.3.7" % "test",
    "org.mongodb"         %%  "casbah"        % "2.7.0-RC0",
    "com.novus"           %%  "salat"         % "1.9.5"
  )
}

Any idea on how to convince Eclipse to find the package?

azyoot
  • 1,162
  • 8
  • 18

3 Answers3

1

Use sbteclipse plugin to configure eclipse project: https://github.com/typesafehub/sbteclipse

atretkow
  • 362
  • 2
  • 8
  • I already used it on the spray template project, it was working just fine, it fails only with casbah – azyoot Feb 24 '14 at 12:18
0

Salat uses Casbah 2.6.4 and has it listed as a dependency[1] so there may be an issue trying to have two different versions. Try changing it to 2.6.4 or removing it and allowing salat to implicitly declare it.

[1] https://github.com/novus/salat/blob/master/project/SalatBuild.scala#L150

Ross
  • 17,861
  • 2
  • 55
  • 73
  • I've removed the scalat dependency, cleaned the project and restarted eclipse. Still no good – azyoot Feb 24 '14 at 17:17
0

I ended up editing the original template spray project by adding the casbah and salat dependencies to the build.sbt, running sbt eclipse, and manually copying the new .classpath file to my imported eclipse project.

azyoot
  • 1,162
  • 8
  • 18
  • You don't need to manually copy it if you use *Import existing project*. This links your workspace project to your checkout location, and every time you use sbteclipse to regenerate the project, changes are picked up after a refresh (or automatically, if you configured Eclipse to watch your file system). – Iulian Dragos Mar 24 '14 at 16:01