1

I'm trying to compile the project in Intellij IDEA which uses Scala 2.10 and requires Java 7 to compile.

I'm using jenv tool for compiling from command line (I've installed it's plugin for Intellij IDEA as well just in case) and after I use Java 7 on jenv and compile the Maven project with this line:

jenv exec mvn clean install

Everything works perfectly.

However when I use Intellij IDEA with Scala plugin the compilation fails. I have Java 1.7 setting set everywhere I've found, in Scala Compiler Server, in Java Compiler, project configuration etc. The failure stacktrace is the following:

Error:scalac: Error: org/jetbrains/jps/incremental/messages/BuildMessage$Kind
java.lang.UnsupportedClassVersionError: org/jetbrains/jps/incremental/messages/BuildMessage$Kind
    at org.jetbrains.jps.incremental.scala.local.AbstractCompiler$ClientReporter.log(AbstractCompiler.scala:92)
    at xsbt.DelegatingReporter.info0(DelegatingReporter.scala:39)
    at scala.tools.nsc.reporters.Reporter$$anonfun$error$1.apply$mcV$sp(Reporter.scala:70)
    at scala.tools.nsc.reporters.Reporter$$anonfun$error$1.apply(Reporter.scala:70)
    at scala.tools.nsc.reporters.Reporter$$anonfun$error$1.apply(Reporter.scala:70)
    at scala.tools.nsc.reporters.Reporter.withoutTruncating(Reporter.scala:42)
    at scala.tools.nsc.reporters.Reporter.error(Reporter.scala:70)
    at scala.tools.nsc.Global.globalError(Global.scala:228)
    at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1564)
    at scala.tools.nsc.Global$Run.compileSources(Global.scala:1552)
    at scala.tools.nsc.Global$Run.compile(Global.scala:1661)
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:115)
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:94)
    at xsbt.CompilerInterface.run(CompilerInterface.scala:22)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:101)
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:47)
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
    at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:32)
    at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)
    at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:68)
    at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:25)
    at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)

As I understand, this means mismatch between the compiled code java version and the version which tries to run it. I've also seen the Unable to copile scala anymore issue created for JetBrains.

So, is there any way I can build this project in Intellij? As I'm stuck with this and can't proceed.

yyunikov
  • 5,719
  • 2
  • 43
  • 78
  • Any other library needs to be 1.7. So if you have a dependency that is 1.8 you would need to find the 1.7 version – bichito Apr 18 '17 at 14:16
  • Not sure if that's the issue. I've tried to delete all dependencies from .m2 folder, recompile it with java 7 and still getting the error. – yyunikov Apr 19 '17 at 07:26
  • deleting dependencies does not solve anything if they are downloaded again as 1.8 byte code. Are you also running everything under 1.7 jvm? – bichito Apr 19 '17 at 12:22
  • It may not be the issue, but it is an easy check. It is better to discard the easy ones earlier than to find they were the were the culprit later – bichito Apr 19 '17 at 12:28
  • http://stackoverflow.com/questions/2466828/java-lang-unsupportedclassversionerror-bad-version-number-in-class-file – bichito Apr 19 '17 at 12:31

2 Answers2

1

The issue seems to be related with Intellij IDEA 2017.1 itself, the bug is already there. I've tried to download version 2016.6.3 and it works well there without any issues.

yyunikov
  • 5,719
  • 2
  • 43
  • 78
0

After reading the new comments to the bug Yuriy linked to, I believe it is now possible to fix this problem without downgrading.

Turning off the external Scala compile server worked for me. It might be necessary to upgrade the Scala plugin version.

In order to turn off the external Scala compile server go to File->Settings...->Languages & Frameworks->Scala Compile Server and uncheck the option to "Use external compile server for scala"

unckeck use external compile server for scala

This options appeared when I updated the Scala plugin to build 2017.2.675 using the Nightly option for the plugin and then restarting IntelliJ.

To Update the plugin go to File->Settings...->Languages & Frameworks->Scala -> Updates, choose Nightly from the drop-down, click "Check For Updates", install and then restart IntelliJ.

enter image description here

mgershen
  • 1,567
  • 16
  • 22