40

I'm using the following:

  • Scala 2.10.4
  • Scalatra 2.2.2
  • sbt 0.13.0
  • java 1.8.0
  • casbah 2.7.2
  • scalatra-sbt 0.3.5

I'm frequently running into this error:

21:32:00.836 [qtp1687101938-55] ERROR o.fusesource.scalate.TemplateEngine - Compilation failed:
error: error while loading CharSequence, class file '/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken
(class java.lang.RuntimeException/bad constant pool tag 18 at byte 10)
error: error while loading ConcurrentMap, class file '/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/rt.jar(java/util/concurrent/ConcurrentMap.class)' is broken
(class java.lang.RuntimeException/bad constant pool tag 18 at byte 61)
two errors found
21:38:03.616 [qtp1687101938-56] ERROR o.fusesource.scalate.TemplateEngine - Compilation failed:
error: error while loading AnnotatedElement, class file '/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class)' is broken
(class java.lang.RuntimeException/bad constant pool tag 18 at byte 76)
one error found

Currently I'm running into this when simply trying to call a .count() on my MongoDB collection.

Upon Googling, it seems like it may be caused by dependency issues. The thing is, I'm using Scalatra just to serve an API and actually don't require any of the scalate stuff. I commented out all references to it, but I still get this. Could it be a dependency issue between the libraries I'm using?

030
  • 10,842
  • 12
  • 78
  • 123
jnfr
  • 941
  • 3
  • 9
  • 21

9 Answers9

50

In my company we had this problem with CharSequence. This is due to Scala 2.10.x does not work with Java 8. This was described in Scalas mailinglist. Switch back to Java 7.

bkowalikpl
  • 817
  • 5
  • 11
12

Switching to Scala 2.10.4 solved the problem for me.

José Ricardo
  • 1,479
  • 1
  • 14
  • 28
4

I have a similar problem on Java 1.8.0 working with Scala 2.10.4 and sbt 0.12.4. But when upgrading to sbt 0.13.7, the problem is solved.

viirya
  • 644
  • 6
  • 8
3

I am seeing the same issue with software requiring Scala 2.9.2+ and Java 1.7 running on Scala 2.10.4 and Java 1.8. Changed to Java 7 via sudo update-alternatives --config java

Edi Bice
  • 566
  • 6
  • 18
0

I solved this by using:

<dependency>
    <groupId>org.scala-lang</groupId>
    <artifactId>scala-library</artifactId>
    <version>2.10.2-RC2</version>
</dependency>

My environment is:

  • JDK 8
  • Maven
  • Scala
spenibus
  • 4,339
  • 11
  • 26
  • 35
Panda1667075
  • 147
  • 1
  • 10
0

I also got the same issue in Ubuntu 14.04 but I solved by removing the scala 2.10 and installing 2.11

wget www.scala-lang.org/files/archive/scala-2.11.7.deb

 

dpkg -i scala-2.11.7.deb

Now try.

Nissa
  • 4,636
  • 8
  • 29
  • 37
Nagaraj Vittal
  • 881
  • 13
  • 26
0

That was a lot of reconfiguration for me to get it to work, here is my (NOW) working build.sbt using, sbt 0.13.15 and scala 2.10.4 and jdk 1.8.1_131

name := "ScalaTelemetryManagerApi"
version := "1.0"
scalaVersion := "2.10.4"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

libraryDependencies ++= {
  Seq(
    "io.spray"            %   "spray-can"     % "1.3.1",
    "io.spray"            %   "spray-routing" % "1.3.1",
    "io.spray"            %   "spray-testkit" % "1.3.1",
    "com.typesafe.akka"   %%  "akka-actor"    % "2.3.2",
    "com.typesafe.akka"   %%  "akka-testkit"  % "2.3.2",
    "org.specs2"          %%  "specs2-core"   % "3.6",
    "com.github.seratch"  %%  "awscala"       % "0.5.+",
    "org.scalaz"      %%  "scalaz-core"   % "7.2.14"
  )
}

resolvers += "Scalaz Bintray Repo" at "https://dl.bintray.com/scalaz/releases"

Revolver.settings

retrieveManaged := true
Sean Bradley
  • 3,254
  • 1
  • 17
  • 10
-1

I hope a stable version of Scala will help you, Try 2.10.x with Java 1.7.x versions for better performance.

I mean it worked for me also in the same.

Murtaza Kanchwala
  • 2,425
  • 25
  • 33
-1

I had the same problem. However by switching to Java 7 my problem is resolved. So now this configuration works for me:

sbt 0.13.8
scala 2.11.7
java 7
Ali
  • 331
  • 2
  • 4