Unable to use ScalaCheck with Scala IDE for Eclipse - scala

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

Related

jOOQ as a dependency in Scala 3 is broken?

I am trying to use jOOQ as dependency in a Scala 3 codebase:
libraryDependencies ++= Seq("org.jooq" % "jooq" % "3.16.6")
However when I try to do an import from this library -- like import org.jooq.DSLContext -- I get a compilation error.
The easiest way to reproduce this is using ammonite:
cs launch ammonite --scala 3.1.3
Loading...
Welcome to the Ammonite Repl 2.5.4-11-4f5bf2aa (Scala 3.1.3 Java 11.0.15)
# import $ivy.`org.jooq:jooq:3.16.6`, org.jooq.DSLContext
Bad symbolic reference. A signature
refers to ApiStatus/T in package org.jetbrains.annotations 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 the signature.
Caught: java.lang.AssertionError: assertion failed: failure to resolve inner class:
externalName = org.jetbrains.annotations.ApiStatus$Experimental,
outerName = org.jetbrains.annotations.ApiStatus,
innerName = Experimental
owner.fullName = org.jetbrains.annotations.ApiStatus
while parsing /Users/horta/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jooq/jooq/3.16.6/jooq-3.16.6.jar(org/jooq/Named.class) while parsing annotations in /Users/horta/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jooq/jooq/3.16.6/jooq-3.16.6.jar(org/jooq/Named.class)
Caught: java.lang.RuntimeException: bad constant pool index: 0 at pos: 740 while parsing annotations in /Users/horta/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jooq/jooq/3.16.6/jooq-3.16.6.jar(org/jooq/Named.class)
...
This is not the complete error, it gives the same type of error on a bunch of different classes, always related with this annotation org.jetbrains.annotations.ApiStatus.Experimental.
I've reproduced this using Java 11 and 18 (openjdk), using SBT and ammonite, with all versions of Scala 3.
When using Scala 2.13.* everything works correctly, we're using that in production.
Any idea what might be going on here? Any potential clues or possible workarounds?
This is fixed in Scala 3 from version 3.2.0-RC1.
See reddit post in r/scala.

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

class java.lang.RuntimeException/Scala class file does not contain Scala annotation

I'm trying to execute a scala code using scala 2.10.2, the code uses some jar libraries compiled with sbt.
I get the following error:
scala: error while loading Order, class file '..\prestashop-scala-client-0.2.4\target\prestasac-0.2.4.jar(co/orderly/prestasac/representations/Order.class)' is broken
(class java.lang.RuntimeException/Scala class file does not contain Scala annotation)
Sources of the prestasac-0.2.4.jar are on github: Order.class
Is there something to do to fix this issue ?
Thank you
Looks like the library is configured to compile against Scala 2.9.1. Major versions of Scala are not binary compatible.
I put the necessary SBT changes here: https://github.com/mpartel/prestashop-scala-client/commit/e9a1df40bfe35518aaebac899e438b9b6fa6d728

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