3

I face this error message when I try to run the project:

Error:scalac: bad symbolic reference to scala.ScalaObject encountered in class file 'package.class'.
Cannot access type ScalaObject in package scala. The current classpath may be
missing a definition for scala.ScalaObject, or package.class may have been compiled against a version that's incompatible with the one found on the current classpath.

There are similar questions here and here, but none seems to be applicable to my case - mine isn't spitting out such messages. The only thing I have to go one is scalaObject.

This is a sudden breakage -- the project was made inside IntelliJ IDEA with sbt and ran find until today. Suddenly, it can't find what it needs.

This is the whole build.sbt file:

name := "MyApp"

libraryDependencies ++= Seq(
  "joda-time" % "joda-time"    % "2.3",
  "org.joda"  % "joda-convert" % "1.6",
  "org.scala-lang" % "scala-swing" % "2.9.2",

How do I troubleshoot this?

Community
  • 1
  • 1
user3308774
  • 1,354
  • 4
  • 16
  • 20

2 Answers2

0

I believe you may have changed sbt.version in project/build.properties or scalaVersion in build.sbt. Or just sbt the launcher. Or the Scala plugin for IntelliJ IDEA. Could that be the case?

I'm basing it on "or package.class may have been compiled against a version that's incompatible with the one found on the current classpath.".

You may want to see update reports in target\resolution-cache\reports.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • Can you elaborate more? I am having a similar problem, and I don't see an 'update' file in `target\resolution-cache\reports`. Even removing all dependencies from my `build.sbt` file I am still getting a similar issue. – Nathaniel Ford Aug 20 '14 at 02:25
0

You mentioned that you are using IntelliJ IDEA. I am using the Scala IDE for Eclipse and I ran across this error. It only occurred when I turned off this option in the IDE config:

withVersionClasspathValidator - Check Scala compatibility of jars in classpath

When this option was turned on, I instead got:

mongo-casbah-commons_2.8.1-2.1.2.jar is cross-compiled with an incompatible version of Scala (2.8.1).

I'm new to Scala, but this seems to be because I'm using Scala 2.11.2 to compile, but I'm including a jar that was built using Scala 2.8.1.

awilkinson
  • 1,601
  • 15
  • 23