Casbah missing reference error for "MongoCursor" using Eclipse - eclipse

I've been getting this error whenever I'm using Scala libraries for MongoDB.
bad symbolic reference. A signature in Implicits.class refers to type MongoCursor in
package com.mongodb which is not available. It may be completely missing from the
current classpath, or the version on the classpath might be incompatible with the
version used when compiling Implicits.class.
I get the error in response to the line:
val client = MongoClient("localhost", 27017)
I've tried different versions of the various jar files, but it hasn't fixed it. I've been using only the most up-to-date versions, so I don't know what the problem is. It won't give me a line reference, and I can't find a reference to a "MongoCursor" type in the Implicits.class source. I get the feeling that I'm missing another library, but I don't know what it would be.
I'm using:
joda-time-2.3.jar
mongo-java-driver-2.11.4.jar
casbah_2.10-2.7.0-SNAPSHOT.jar
casbah-commons_2.10-2.7.0-SNAPSHOT.jar
casbah-core_2.10-2.7.0-SNAPSHOT.jar
casbah-gridfs_2.10-2.7.0-SNAPSHOT.jar
casbah-query_2.10-2.7.0-SNAPSHOT.jar

You will need to update the Java driver as the 2.7.0-SNAPSHOT relies on the mongo-java-driver 2.12.0-SNAPSHOT - then it should be able to find MongoCursor correctly.

Related

Error while including casbah dependencies

I am facing problem in getting started with casabah to integrate scala and mongoDb. I am using Spring Tool Suite(STS) and imported the following jar files :
spring-data-mongodb-1.6.0.RELEASE.jar
com.mongodb.jar
casbah-commons_2.10-2.7.2.jar
casbah-query_2.10-2.7.2.jar
joda-time-2.1.jar
slf4j-api-1.7.7.jar
casbah-gridfs_2.10-2.5.0.jar
scalaj-collection_2.10-1.4.jar
slf4j-simple-1.7.7.jar
casbah-core_2.10-2.7.2.jar
mongo-2.10.0.jar
mongo-java-driver-2.10.0.jar
However, I get an error.
Error:Description Resource Path Location Type bad symbolic reference. A signature in Implicits.class refers to type Cursor in package com.mongodb which is not available. It may be completely missing from the current classpath, or the version on the classpath might be incompatible with the version used when compiling Implicits.class.
I read a couple of posts that says the problem is with the version in mongo-java-driver so i tried with mongo-java-driver-2.10.1.jar as well , But it was still giving me an error.
Could someone please help me resolve this error??
Thanks a lot in advance!!!
It looks like its a dependency issue. Casbah is built upon a fixed version of the Mongo Java driver so is reliant on a specific binary compatible version.
The Casbah version numbers should all be the same - above you mainly have Casbah 2.7.2 but the gridfs version is wrong: casbah-gridfs_2.10-2.5.0.jar.
Also, Casbah 2.7.2 relies on version 2.12.2 of the Mongo Java Driver, however, the latest version of Casbah is 2.7.3 which relies on version 2.12.3 of the Mongo Java Driver.
To make this simpler there is a all dependencies jar for Casbah that includes the latest version of the java driver and all the other relevant dependencies. Alternatively, the pom file should point all dependent packages which declare their dependencies. (As Casbah is split into sub packages the casbah-commons pom has all the external dependencies listed).

import lift mapper caught an error missing jar file

hi im creating a lift scala application
this is my problem
when i import net.liftweb.mapper._ package the compiler gives me error...
i tried to add lift-mapper_2.9.1-2.4-M4.jar jar file to build path ,but the error exists..!
the compiler shows..
bad symbolic reference. A signature in package.class refers to term db in package net.liftweb which is not available. It may be completely missing from
the current classpath, or the version on the classpath might be incompatible with the version used when compiling package.class.
Try to add the mapper via SBT or maven configuration?
Anyway, Scala-2.9.1 and Lift 2.4-M4 are very-very out of date. Better use something like that for a good start: https://github.com/lift/lift_25_sbt/
It works out of the box, and you'll only have to add 1 line to add the mapper support for it. (After that, all dependencies would be downloaded and added to the project automatically, by SBT.)

strange error message: bad symbolic reference. A signature in package.class refers to term apache in package org which is not available

When I tried to compile simple typesafe' akka program (scala 2.10, akka, 2.1.0):
scalac -cp "akka-actor_2.10-2.1.0.jar:akka-camel_2.10-2.1.0.jar" write2.scala
error: bad symbolic reference. A signature in package.class refers to term apache
in package org which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling package.class.
error: bad symbolic reference. A signature in package.class refers to term camel
in value org.apache which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling package.class.
write2.scala:21: error: bad symbolic reference. A signature in package.class refers to term model
in value org.camel which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling package.class.
val mina = system.actorOf(Props[MyEndPoint])
three errors found
The code on line 21:
val mina = system.actorOf(Props[MyEndPoint])
(The same program was compiled correctly in Eclipse, so the source code is OK)
Most likely some jar file is missing in -cp variable. The question is what mean that strange/useless error message.
Thanks, Tomas
The message says "There's no package org.apache in my classpath, and I need it while reading file package.class". Pass -Ylog-classpath to scalac and look at what is the real classpath that gets to the compiler.
To me it was JDK not set on PATH neither JAVA_HOME
You can add JAVA_HOME to point to your JDK root folder and add jdk/bin folder (wich inludes javac) directly to the path.
You can refer to the Oracle docs for instruccions on how to add the path
http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html
In case this helps anyone in the future, I was having this problem with an application I adopted after adding a new class. It turned out that the capitalization in the package name in each class within the package and the actual directory structure were different. Once I lower-cased all of the directory it started working again.
First time Scala user. I had some problems in configuring my eclipse and I used to get:
Error:scalac: bad symbolic reference. A signature in package.class refers to type compileTimeOnly
in package scala.annotation which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling package.class.
Finally found that scala test version 2.11 and compiler version should match.
Downloaded scala version 2.11-RC1

Library 'scala-2.10.0-RC1 not used' thrown by IntelliJ integrating a Play 2 app

I've just generated a fresh Play! application, version 2.1-RC1.
This one includes two Scala compiler/library couple:
Scala 2.9.2
Scala 2.10.0-RC1
The whole well compiles within IntelliJ IDEA 12 but a warning occurs as the image shows it:
It would seem so that another compiler is used instead 2.10.0-RC1.
However, my Scala facet is configured as this:
What might be the warning cause?
I precise that I've got also a Scala variable environment (used for shell Scala commands) configured to point to scala-2.10.0-RC2, but I well imagine that IntelliJ is based on library that user indicates in Scala Facet.
You can remove that .jar from the libraries, it's not used because it's redundantly generated by IntelliJ SBT plubin.

Is it possible to compile files in sbt plugin?

I have an sbt plugin, that needs to get compiler AST's from source files. I tried to create a new compiler with the following code:
val settings = new Settings
settings.usejavacp.value = true
val compiler = new tools.nsc.interactive.Global(settings, new StoreReporter())
But I get the following error:
java.lang.Error: typeConstructor inapplicable for <none>
It seems that it somehow clashes with sbt's internal compiler.
So, is there a way to get AST's for those files from inside sbt?
Or maybe it is possible to get them from sbt's compiler directly? (that would be even better, since I would not need to recompile everything every time)
EDIT:
Seems that using tools.nsc.Global instead of "interactive" one does not throw an error, but I don't know how to get ASTs from it.
EDIT:
Well, tools.nsc.Global fails with the same error when I try to compile some files :(
SBT FAQ states that I should use some "representative type" when initializing my compiler - settings.embeddedDefaults[MyType]. But I can't figure out exactly what I should send to it. Can somebody help me with it?
This line means to use the value of the java.class.path system property as the classpath for the compiler:
settings.usejavacp.value = true
In sbt, this is only going to include the launcher jar because that is all that is on the classpath when the jvm is initialized.
The launcher jar has been processed with ProGuard, so it contains incomplete Scala classes and should never be on a compiler classpath.
Instead, explicitly set the classpath according to your needs:
settings.classpath.value = "some;classpath"