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

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

Related

Can't expand macros compiled by previous versions of Scala

I changed my Scala version from 2.10.x to 2.11.8. I am getting some compilation issues. I tried, but still not able to resolve because I am poor in Scala and sbt.
WebService.scala:36: can't expand macros compiled by previous versions of Scala
[error] logger.error(s"WebService.getSiteData(${Id}): Unknown Error, Error Message: $e")
What might be the issue here?
I resolved this issue but it not a single thing, I did couple of things:
First I gone through the error location in WebService.scala.
Then to the corresponding "Logger" class.
I check from which jar that "Logger" class coming.
I found that it referring to some thing else jar than what I am expecting.
That jar is coming from one of my dependent project (modules) so in build.sbt, those dependent jars I excluded that wrong jar which I found.
After I changed the code in WebService.scala, I removed that import for logger and added new import having Logger what I expecting. I did same all the other places in my project.
WebService.scala:36: can't expand macros compiled by previous versions of Scala
[error] logger.error(s"WebService.getSiteData(${Id}): Unknown Error, Error Message: $e")
This is not particular to logger issue. If you are getting "can't expand macros compiled by previous versions of Scala" issue", you have to do same procedure for corresponding to your error (my case logger).
First time, I search online regarding this issue, I found same issue facing lot of people, but different library classes (I face Logger class issue).

Unable to use ScalaCheck with Scala IDE for Eclipse

I'm trying to follow the instructions in this guide http://lamp.epfl.ch/files/content/sites/lamp/files/teaching/progfun/ScalacheckTutorial.html
in order to use ScalaCheck in Scala IDE.
However, when I create the first file StringSpecification.scala, with this code:
package pp.scalacheck
import org.scalacheck._
import Prop.forAll
object StringSpecification extends Properties("String") {
property("startsWith") = forAll { (x: String, y: String) =>
(x + y).startsWith(x)
}
}
I get the following error in Scala IDE:
bad symbolic reference to scala.util.parsing encountered in class file
'CmdLineParser.class'. Cannot access term parsing in package
scala.util. The current classpath may be missing a definition for
scala.util.parsing, or CmdLineParser.class may have been compiled
against a version that's incompatible with the one found on the
current classpath. (NOTE: It looks like the scala-parser-combinators
module is missing; try adding a dependency on "org.scala-lang.modules"
: "scala-parser-combinators". See
http://docs.scala-lang.org/overviews/core/scala-2.11.html for more
information.)
Error in Scala compiler: bad symbolic reference to
scala.util.parsing.combinator encountered in class file
'CmdLineParser.class'. Cannot access term combinator in value
scala.util.parsing. The current classpath may be missing a definition
for scala.util.parsing.combinator, or CmdLineParser.class may have
been compiled against a version that's incompatible with the one found
on the current classpath. (NOTE: It looks like the
scala-parser-combinators module is missing; try adding a dependency on
"org.scala-lang.modules" : "scala-parser-combinators". See
http://docs.scala-lang.org/overviews/core/scala-2.11.html for more
information.)
SBT builder crashed while compiling. The error message is 'bad
symbolic reference to scala.util.parsing.combinator encountered in
class file 'CmdLineParser.class'. Cannot access term combinator in
value scala.util.parsing. The current classpath may be missing a
definition for scala.util.parsing.combinator, or CmdLineParser.class
may have been compiled against a version that's incompatible with the
one found on the current classpath. (NOTE: It looks like the
scala-parser-combinators module is missing; try adding a dependency on
"org.scala-lang.modules" : "scala-parser-combinators". See
http://docs.scala-lang.org/overviews/core/scala-2.11.html for more
information.)'. Check Error Log for details.
I'm using the latest stable version of Scla IDE (for Eclipse) (3.0.4), ScalaCheck (2.11-1.11.6) and Scala (2.11.2), and I'm running on Windows.
What could be causing this error?
When I added this jar to the project I was able to build the example files:
http://search.maven.org/#artifactdetails%7Corg.scala-lang.modules%7Cscala-parser-combinators_2.11%7C1.0.2%7Cbundle

Casbah missing reference error for "MongoCursor" using 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.

scala & intellij : difficulties to create a runnnable jar

I can't launch a scala jar; when I launch it I get the error "Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/immutable/List" which seems to mean the scala library is not loaded...
this is a screenshot showing a lot of informations on the artifact window.
here is the manifest:
Manifest-Version: 1.0
Class-Path: libs/scala-library-2.10.0.jar libs/commons-logging-1.1.1.j
ar libs/jcip-annotations-1.0.jar libs/jwnl-1.4_rc3.jar libs/laf-plugi
n-7.2.1.jar libs/laf-widget-7.2.1.jar libs/miglayout-core-4.2.jar lib
s/miglayout-swing-4.2.jar libs/scala-actors.jar libs/scala-library.ja
r libs/scala-swing.jar libs/slf4j-api-1.6.4.jar libs/slick_2.10-1.0.0
.jar libs/sqlite-jdbc-3.7.2.jar libs/substance-7.2.1.jar libs/trident
-7.2.1-swing.jar
Main-Class: Fenetre
and when I enter "java xf myJar.jar", there are extracted files in the directory:
- .class files
- in the libs folder, there are the libraries INCLUDING scala-library.jar & scala-library-2.10.0.jar(I specified only one of these two files in the manifest to avoid conflicts)
can you help me?
I'm new to Scala and don't know what the problem is however I've been compiling "fat jars" which include all the required libs.
I've been using https://github.com/sbt/sbt-assembly to do this successfully.
Despite what your manifest is telling you, when you run the application you either do not have the scala-library included in your class path or there's some confusion when you attempt to import List. Scala should automatically import the immutable collection classes in your project with the root Predef implementation.
Predef provides type aliases for types which are commonly used, such as the immutable collection types scala.collection.immutable.Map, scala.collection.immutable.Set, and the scala.collection.immutable.List constructors (scala.collection.immutable.:: and scala.collection.immutable.Nil). The types Pair (a scala.Tuple2) and Triple (a scala.Tuple3), with simple constructors, are also provided.
Predef in core Scaladocs
Try printing the classpath from within your app to confirm.
Although not pertinent to your question, I would recommend using SBT for dependency management now that IntelliJ IDEA 13 has full SBT integration support. Your collaborators not using IntelliJ will also be happier because SBT gives them more options for build technologies, editors, and other tooling when working on the project.

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.)