Casbah MongoDB driver compiler error - mongodb

I'm using the Casbah driver for MongoDB and while I compiled my project, it fails with the following error:
[INFO] Compiling 12 source files to /core/target/classes at 1394903201140
[ERROR] error: bad symbolic reference. A signature in MongoClient.class refers to type MongoClientURI
[INFO] in package com.mongodb which is not available.
[INFO] It may be completely missing from the current classpath, or the version on
[INFO] the classpath might be incompatible with the version used when compiling MongoClient.class.
[ERROR] error: bad symbolic reference. A signature in MongoClient.class refers to type MongoClient
[INFO] in package com.mongodb which is not available.
[INFO] It may be completely missing from the current classpath, or the version on
[INFO] the classpath might be incompatible with the version used when compiling MongoClient.class.
[ERROR] two errors found
I'm having the following setup as my maven dependency:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>casbah_2.10</artifactId>
<version>2.7.0-RC2</version>
</dependency>
Why would it now fail during compilation? Any clues what to look for or what to change? Additionally, I also see the following warnings:
[WARNING] Expected all dependencies to require Scala version: 2.10.3
[WARNING] org.mongodb:casbah_2.10:2.7.0-RC2 requires scala version: 2.10.3
[WARNING] org.mongodb:casbah-commons_2.10:2.7.0-RC2 requires scala version: 2.10.3
[WARNING] com.github.nscala-time:nscala-time_2.10:0.6.0 requires scala version: 2.10.2
Has this got any relation to the compilation failure? Additionally, I ran maven in debug mode and this is what I see in my classpath:
[DEBUG] Classpath: [/../../target/classes
/Softwares/maven-repo/org/scala-lang/scala-library/2.10.3/scala-library-2.10.3.jar
/Softwares/maven-repo/org/mongodb/casbah-commons_2.10/2.7.0-RC2/casbah-commons_2.10-2.7.0-RC2.jar
/Softwares/maven-repo/com/github/nscala-time/nscala-time_2.10/0.6.0/nscala-time_2.10-0.6.0.jar
/Softwares/maven-repo/org/joda/joda-convert/1.2/joda-convert-1.2.jar
/Softwares/maven-repo/org/slf4j/slf4j-api/1.6.0/slf4j-api-1.6.0.jar
/Softwares/maven-repo/org/mongodb/casbah-core_2.10/2.7.0-RC2/casbah-core_2.10-2.7.0-RC2.jar
/Softwares/maven-repo/org/mongodb/casbah-query_2.10/2.7.0-RC2/casbah-query_2.10-2.7.0-RC2.jar
/Softwares/maven-repo/org/mongodb/casbah-gridfs_2.10/2.7.0-RC2/casbah-gridfs_2.10-2.7.0-RC2.jar
/Softwares/maven-repo/com/novus/salat-core_2.9.2/0.0.8/salat-core_2.9.2-0.0.8.jar
/Softwares/maven-repo/com/novus/salat-util_2.9.2/0.0.8/salat-util_2.9.2-0.0.8.jar
/Softwares/maven-repo/org/scala-lang/scalap/2.9.2/scalap-2.9.2.jar
/Softwares/maven-repo/org/scala-lang/scala-compiler/2.9.2/scala-compiler-2.9.2.jar
/Softwares/maven-repo/org/mongodb/mongo-java-driver/2.7.3/mongo-java-driver-2.7.3.jar
/Softwares/maven-repo/com/mongodb/casbah/casbah-core_2.9.1/2.1.5-1/casbah-core_2.9.1-2.1.5-1.jar
/Softwares/maven-repo/com/mongodb/casbah/casbah-commons_2.9.1/2.1.5-1/casbah-commons_2.9.1-2.1.5-1.jar
/Softwares/maven-repo/org/scala-tools/time/time_2.9.1/0.5/time_2.9.1-0.5.jar
/Softwares/maven-repo/org/scalaj/scalaj-collection_2.9.1/1.2/scalaj-collection_2.9.1-1.2.jar
/Softwares/maven-repo/com/mongodb/casbah/casbah-query_2.9.1/2.1.5-1/casbah-query_2.9.1-2.1.5-1.jar
/Softwares/maven-repo/net/liftweb/lift-json_2.9.1/2.4/lift-json_2.9.1-2.4.jar
/Softwares/maven-repo/com/thoughtworks/paranamer/paranamer/2.3/paranamer-2.3.jar
/Softwares/maven-repo/com/typesafe/config/1.0.2/config-1.0.2.jar
/Softwares/maven-repo/joda-time/joda-time/2.3/joda-time-2.3.jar]
I do not understand from where did the other dependencies especially the ones like casbah-core_2.9.1, casbah-query_2.9.1 make it to my classpath? I do not have them as my maven dependencies in my pom.xml! It is confusing.

I figured out what the problem is. I had an additional dependency to the salat framework that I do not use nut somehow was added during evaluation. It actually was pulling in those additional jar files into the classpath which actually seems to be the reason for this error!

Related

Library cannot be resolved

When I package Scala project using SBT, I face the following problem:
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from D:\marathon-master\project
Version '20170916T025229' is not fully supported, please update the git tags.
[info] Set current project to marathon (in build file:/D:/marathon-master/)
[info] Constructing RAML model
java.lang.RuntimeException: Library cannot be resolved: D:\marathon-master\docs\docs\rest-api\public\api\appContainer.raml -- D:\marathon-master\docs\docs\rest-api\public\api\v2/types/app.raml [line=6, col=17]
at scala.sys.package$.error(package.scala:27)
...
[error] (marathon/compile:ramlGenerate) Library cannot be resolved: D:\marathon-master\docs\docs\rest-api\public\api\appContainer.raml -- D:\marathon-master\docs\docs\rest-api\public\api\v2/types/app.raml [line=6, col=17]
And the 5-7 lines code in app.raml like that:
uses:
appContainer: appContainer.raml
artifact: artifact.raml
the directory of app.raml and appContainer.raml is "D:\marathon-master\docs\docs\rest-api\public\api\v2/types/" both. So I change 6 line of app.raml like that:
appContainer: v2/types/appContainer.raml
But when I run "sbt package" again, a warning shows up:
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m;
support was removed in 8.0
[info] Loading project definition from D:\marathon-master\project
Version '20170916T025721' is not fully supported, please update the git tags.
[info] Set current project to marathon (in build file:/D:/marathon-master/)
[warn] File D:\marathon-master\docs\docs\rest-api\public\api\v2\types\v2\types\appContainer.raml does not exist (referenced by
D:\marathon-master\docs\docs\rest-api\public\api\v2\types\app.raml)
[info] Constructing RAML model
java.lang.RuntimeException: Library cannot be resolved: D:\marathon-master\docs\docs\rest-api\public\api\artifact.raml -- D:\marathon-master\docs\docs\rest-api\public\api\v2/types/app.raml [line=7, col=13]
...
[error] (marathon/compile:ramlGenerate) Library cannot be resolved:
D:\marathon-master\docs\docs\rest-api\public\api\artifact.raml -- D:\marathon-master\docs\docs\rest-api\public\api\v2/types/app.raml [line=7, col=13]
why have this warning? Any idea?

gwt 2.8 throws exception when compiling with guava 20

I am trying to upgrade to the newly released guava-gwt 20. I am getting this exception when I do a gwt compile. I did not get any errors prior to upgrading to guava 20. I am using the gwt 2.8.0. Is there a module I need to reference? Much appreciated!
[INFO] Tracing compile failure path for type 'java.util.concurrent.Future'
[INFO] [ERROR] Errors in 'jar:file:/Users/Eric/.m2/repository/com/google/guava/guava-gwt/20.0/guava-gwt-20.0.jar!/java/util/super/java/util/concurrent/Future.java'
[INFO] [ERROR] Line 32: No source code is available for type java.lang.InterruptedException; did you forget to inherit a required module?
[INFO] Tracing compile failure path for type 'java.util.concurrent.CountDownLatch'
[INFO] [ERROR] Errors in 'jar:file:/Users/Eric/.m2/repository/com/google/guava/guava-gwt/20.0/guava-gwt-20.0.jar!/java/util/super/java/util/concurrent/CountDownLatch.java'
[INFO] [ERROR] Line 30: No source code is available for type java.lang.InterruptedException; did you forget to inherit a required module?
[INFO] [ERROR] Aborting compile due to errors in some input files
This appears to be a Guava bug. Until we fix it, you can work around it by adding <inherits name="java.lang.Lang"/> to your .gwt.xml.

sbt console doesn't allow input

I've been trying to use sbt for one of my projects, however I've ran into the following problem - when I try to use sbt console to get the scala's REPL, it just doesn't allow any input. Example session:
[lared#lt foo]$ sbt
[info] Set current project to foo (in build file:/tmp/foo/)
> console
[info] Updating {file:/tmp/foo/}foo...
[info] Resolving org.scala-lang#scala-reflect;2.10.3 ...
[info] Done updating.
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.3 (OpenJDK 64-Bit Server VM, Java 1.8.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
I can not type anything. It doesn't seem to take much RAM/CPU time. The problem is reproducible in any directory, regardless of if it does have a proper project structure (for example the SBT Hello World tutorial) or not.
I'm using sbt 0.13.1 and the JDK/Scala versions as seen above on Fedora 21.
The problem was solved by deleting ~/.ivy2/ and (perhaps unrelated) migration to Oracle Java 1.7 SDK.
I could not find a way to get the Fedora 24 installed sbt 0.13.1 console to work either so I downloaded the latest sbt (currently 0.13.12), unzipped into /opt and add the sbt binary to my path before /usr/bin/sbt.
The earlier suggestion to delete ~/.ivy2 did not work for me.

How do I resolve "error: bad symbolic reference" for dependencies using maven-scala plugin?

I'm building a small database query utility using Scala and Slick, with Maven as my build and packaging tool.
My code compiles without any syntax errors, but the build fails with this:
[INFO] --- maven-scala-plugin:2.15.0:compile (default) # origdups ---
[INFO] Checking for multiple versions of scala
[INFO] includes = [**/*.scala,**/*.java,]
[INFO] excludes = []
[INFO] /home/lreeder/dev/scala/origdups/src/main/scala:-1: info: compiling
[INFO] Compiling 4 source files to /home/lreeder/dev/scala/origdups/target/classes at 1375638972068
[INFO] No known dependencies. Compiling everything
[ERROR] error: bad symbolic reference. A signature in Mapper.class refers to term runtime
[INFO] in package scala.reflect which is not available.
[INFO] It may be completely missing from the current classpath, or the version on
[INFO] the classpath might be incompatible with the version used when compiling Mapper.class.
(several more similar errors)
Note that the Mapper class is not my code. I think it's part of Slick? I'm using Scala 2.10.1 for the maven-scala plugin:
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.1</version>
</dependency>
and Slick 2.10 (currently build with Scala 2.10.1):
<dependency>
<groupId>com.typesafe.slick</groupId>
<artifactId>slick_2.10</artifactId>
<version>1.0.1</version>
</dependency>
I've compiled with maven debug turned on, and this is the Java call that generates the errors above.
/usr/local/jdk1.7.0_21/jre/bin/java -classpath
/home/lreeder/.m2/repository/org/scala-lang/scala-library/2.10.1/scala-library-2.10.1.jar:/home/lreeder/.m2/repository/org/scala-lang/scala-compiler/2.10.1/scala-compiler-2.10.1.jar:/home/lreeder/.m2/repository/org/scala-lang/scala-reflect/2.10.1/scala-reflect-2.10.1.jar:/home/lreeder/.m2/repository/org/scala-tools/maven-scala-plugin/2.15.0/maven-scala-plugin-2.15.0.jar
-Xbootclasspath/a:/home/lreeder/.m2/repository/org/scala-lang/scala-library/2.10.1/scala-library-2.10.1.jar
org_scala_tools_maven_executions.MainWithArgsInFile
scala.tools.nsc.Main /tmp/scala-maven-6314934214401019063.args
What am I missing here? What needs to be set in the maven-scala plugin configuration to get rid of these errors.
This error:
error: bad symbolic reference. A signature in Mapper.class refers to term runtime in package scala.reflect which is not available.
is saying that scala.reflect.runtime is missing from the classpath. And, indeed, upon checking /tmp/scala-maven-6314934214401019063.args, it was not in the classpaths listed there.
Slick 2.10 has dependencies on the Scala reflection package. See https://github.com/slick/slick/blob/master/src/main/scala/scala/slick/direct/MetadataProvider.scala. So, the POM for Slick should list scala-reflect so that other projects can resolve it as a transitive dependency. However, slick_2.10-1.0.1.pom does not list scala-reflect.
Adding scala-reflect as a dependency in my own project POM fixed this.

Problem upgrading to GWT 2.3.0

I'm totally flummoxed by a GWT problem, and have no clue how to interpret the GWT log or how to troubleshoot the problem. I'm working on a fairly trivial template project. I upgraded to GWT 2.3.0 and am now running into the following issue when compiling the module using the maven-gwt-plugin:
[INFO] --- gwt-maven-plugin:2.3.0:compile (default) # gaewebtemplate ---
[INFO] auto discovered modules [stuff.gaegwttemplate.Main, stuff.gaegwttemplate.security.SecurityRequest]
[INFO] Loading inherited module 'com.google.gwt.activity.Activity'
[INFO] Loading inherited module 'com.google.gwt.place.Place'
[INFO] Loading inherited module 'com.google.gwt.user.User'
[INFO] Loading inherited module 'com.google.gwt.animation.Animation'
[INFO] Loading inherited module 'com.google.gwt.core.Core'
[INFO] Loading inherited module 'com.google.gwt.core.CrossSiteIframeLinker'
[INFO] [ERROR] Unable to load class 'com.google.gwt.core.linker.DirectInstallLinker'
[INFO] java.lang.ClassNotFoundException: com.google.gwt.core.linker.DirectInstallLinker
< Huge stack-trace removed >
[INFO] [ERROR] Failure while parsing XML
[INFO] com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
< Huge stack-trace removed >
[INFO] [ERROR] Unexpected error while processing XML
[INFO] com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
The two stack traces and cryptic error messages above is then repeated creating page after page of (as far as I can tell) completely useless log information.
Does anyone know what might be going on here? Any idea what logging "strategy" Google is using here :).
Gunnar,
I ran into a similar issue. If you are trying to use a GWT SDK newer than the maven plugin, you have to also point the maven plugin to that SDK, like this:
http://mojo.codehaus.org/gwt-maven-plugin/user-guide/using-different-gwt-sdk-version.html
Otherwise, I believe the maven plugin will still use the GWT version that matches it (if you were to delete your GWT jars from your maven repo, you could confirm this by seeing it downloading the older version.)
The DirectInstallLinker class doesn't appear to be present in GWT 2.3, but I do see it in trunk - are you sure you are using 2.3.0? To get this error, it seems likely that you have at least one copy of something newer than 2.3.0 on your classpath.
GWT 2.3.0 was released on May 2, while the DirectInstallLinker doesn't appear to have been added to source until May 6.
The GWT compiler is using the TreeLogger class, built in to GWT as a way for the compiler and generators to nest debug/error/info messages.
I got the same error when upgrading from gwt 2.3 to gwt 2.4. I was being silly and updated the version on the gwt-user dependency but not on the gwt-dev dependency. So, check that you aren't also being silly.