Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compilation failed: error while loading AnnotatedElement, ConcurrentMap, CharSequence from Java 8 under Scala 2.10?

Tags:

scala

sbt

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?

like image 310
jnfr Avatar asked Jun 13 '14 04:06

jnfr


4 Answers

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.

like image 91
bkowalikpl Avatar answered Oct 17 '22 10:10

bkowalikpl


Switching to Scala 2.10.4 solved the problem for me.

like image 31
José Ricardo Avatar answered Oct 17 '22 09:10

José Ricardo


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.

like image 4
viirya Avatar answered Oct 17 '22 10:10

viirya


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

like image 3
Edi Bice Avatar answered Oct 17 '22 09:10

Edi Bice