Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of scalac ServerException with IntelliJ Idea

This error prevents me from running the project.

Here are versions info :

~ ❯❯❯ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
~ ❯❯❯ scala -version
cat: /release: No such file or directory
Scala code runner version 2.12.1 -- Copyright 2002-2016, LAMP/EPFL and Lightbend, Inc.

And I use IntelliJ 2016.3

In an external terminal and sbt, it works !

Error:scalac: Error: org.jetbrains.jps.incremental.scala.remote.ServerException
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at sbt.compiler.RawCompiler.apply(RawCompiler.scala:26)
    at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1$$anonfun$apply$2.apply(AnalyzingCompiler.scala:146)
    at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1$$anonfun$apply$2.apply(AnalyzingCompiler.scala:142)
    at sbt.IO$.withTemporaryDirectory(IO.scala:291)
    at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1.apply(AnalyzingCompiler.scala:142)
    at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1.apply(AnalyzingCompiler.scala:139)
    at sbt.IO$.withTemporaryDirectory(IO.scala:291)
    at sbt.compiler.AnalyzingCompiler$.compileSources(AnalyzingCompiler.scala:139)
    at sbt.compiler.IC$.compileInterfaceJar(IncrementalCompiler.scala:52)
    at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$.org$jetbrains$jps$incremental$scala$local$CompilerFactoryImpl$$getOrCompileInterfaceJar(CompilerFactoryImpl.scala:93)
    at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$$anonfun$getScalac$1.apply(CompilerFactoryImpl.scala:50)
    at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$$anonfun$getScalac$1.apply(CompilerFactoryImpl.scala:49)
    at scala.Option.map(Option.scala:146)
    at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.getScalac(CompilerFactoryImpl.scala:49)
    at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.createCompiler(CompilerFactoryImpl.scala:22)
    at org.jetbrains.jps.incremental.scala.local.CachingFactory$$anonfun$createCompiler$1.apply(CachingFactory.scala:24)
    at org.jetbrains.jps.incremental.scala.local.CachingFactory$$anonfun$createCompiler$1.apply(CachingFactory.scala:24)
    at org.jetbrains.jps.incremental.scala.local.Cache$$anonfun$getOrUpdate$2.apply(Cache.scala:20)
    at scala.Option.getOrElse(Option.scala:121)
    at org.jetbrains.jps.incremental.scala.local.Cache.getOrUpdate(Cache.scala:19)
    at org.jetbrains.jps.incremental.scala.local.CachingFactory.createCompiler(CachingFactory.scala:23)
    at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:22)
    at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:67)
    at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:24)
    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:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
Caused by: java.lang.VerifyError: Uninitialized object exists on backward branch 209
Exception Details:
  Location:
    scala/collection/immutable/HashMap$HashTrieMap.split()Lscala/collection/immutable/Seq; @249: goto
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: 2ab6 0057 04a0 001e b200 afb2 00b4 04bd
    0000010: 0002 5903 2a53 c000 b6b6 00ba b600 bec0
    0000020: 00c0 b02a b600 31b8 003b 3c1b 04a4 015e
    0000030: 1b05 6c3d 2a1b 056c 2ab6 0031 b700 c23e
    0000040: 2ab6 0031 021d 787e 3604 2ab6 0031 0210
    0000050: 201d 647c 7e36 05bb 0014 59b2 00b4 2ab6
    0000060: 0033 c000 b6b6 00c6 b700 c91c b600 cd3a
    0000070: 0619 06c6 001a 1906 b600 d1c0 007d 3a07
    0000080: 1906 b600 d4c0 007d 3a08 a700 0dbb 00d6
    0000090: 5919 06b7 00d9 bf19 073a 0919 083a 0abb
    00000a0: 0002 5915 0419 09bb 0014 59b2 00b4 1909
    00000b0: c000 b6b6 00c6 b700 c903 b800 df3a 0e3a
    00000c0: 0d03 190d b900 e301 0019 0e3a 1136 1036
    00000d0: 0f15 0f15 109f 0027 150f 0460 1510 190d
    00000e0: 150f b900 e602 00c0 0005 3a17 1911 1917
    00000f0: b800 ea3a 1136 1036 0fa7 ffd8 1911 b800
    0000100: eeb7 005c 3a0b bb00 0259 1505 190a bb00
    0000110: 1459 b200 b419 0ac0 00b6 b600 c6b7 00c9
    0000120: 03b8 00df 3a13 3a12 0319 12b9 00e3 0100
    0000130: 1913 3a16 3615 3614 1514 1515 9f00 2715
    0000140: 1404 6015 1519 1215 14b9 00e6 0200 c000
    0000150: 053a 1819 1619 18b8 00f1 3a16 3615 3614
    0000160: a7ff d819 16b8 00ee b700 5c3a 0cb2 00f6
    0000170: b200 b405 bd00 0259 0319 0b53 5904 190c
    0000180: 53c0 00b6 b600 bab6 00f9 b02a b600 3303
    0000190: 32b6 00fb b0                           
  Stackmap Table:
    same_frame(@35)
    full_frame(@141,{Object[#2],Integer,Integer,Integer,Integer,Integer,Object[#105]},{})
    append_frame(@151,Object[#125],Object[#125])
    full_frame(@209,{Object[#2],Integer,Integer,Integer,Integer,Integer,Object[#105],Object[#125],Object[#125],Object[#125],Object[#125],Top,Top,Object[#20],Object[#55],Integer,Integer,Object[#103]},{Uninitialized[#159],Uninitialized[#159],Integer,Object[#125]})
    full_frame(@252,{Object[#2],Integer,Integer,Integer,Integer,Integer,Object[#105],Object[#125],Object[#125],Object[#125],Object[#125],Top,Top,Object[#20],Object[#55],Integer,Integer,Object[#103]},{Uninitialized[#159],Uninitialized[#159],Integer,Object[#125]})
    full_frame(@312,{Object[#2],Integer,Integer,Integer,Integer,Integer,Object[#105],Object[#125],Object[#125],Object[#125],Object[#125],Object[#2],Top,Object[#20],Object[#55],Integer,Integer,Object[#103],Object[#20],Object[#55],Integer,Integer,Object[#103]},{Uninitialized[#262],Uninitialized[#262],Integer,Object[#125]})
    full_frame(@355,{Object[#2],Integer,Integer,Integer,Integer,Integer,Object[#105],Object[#125],Object[#125],Object[#125],Object[#125],Object[#2],Top,Object[#20],Object[#55],Integer,Integer,Object[#103],Object[#20],Object[#55],Integer,Integer,Object[#103]},{Uninitialized[#262],Uninitialized[#262],Integer,Object[#125]})
    full_frame(@395,{Object[#2],Integer},{})
    at scala.collection.immutable.HashMap$.scala$collection$immutable$HashMap$$makeHashTrieMap(HashMap.scala:179)
    at scala.collection.immutable.HashMap$.scala$collection$immutable$HashMap$$makeHashTrieMap(HashMap.scala:183)
    at scala.collection.immutable.HashMap$HashMap1.updated0(HashMap.scala:211)
    at scala.collection.immutable.HashMap.$plus(HashMap.scala:59)
    at scala.collection.immutable.HashMap.$plus(HashMap.scala:62)
    at scala.collection.immutable.Map$Map4.updated(Map.scala:201)
    at scala.collection.immutable.Map$Map4.$plus(Map.scala:202)
    at scala.collection.immutable.Map$Map4.$plus(Map.scala:180)
    at scala.collection.mutable.MapBuilder.$plus$eq(MapBuilder.scala:29)
    at scala.collection.mutable.MapBuilder.$plus$eq(MapBuilder.scala:25)
    at scala.collection.generic.Growable.$anonfun$$plus$plus$eq$1(Growable.scala:59)
    at scala.collection.generic.Growable$$Lambda$19/1738535896.apply(Unknown Source)
    at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:52)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
    at scala.collection.generic.Growable.$plus$plus$eq(Growable.scala:59)
    at scala.collection.generic.Growable.$plus$plus$eq$(Growable.scala:50)
    at scala.collection.mutable.MapBuilder.$plus$plus$eq(MapBuilder.scala:25)
    at scala.collection.generic.GenMapFactory.apply(GenMapFactory.scala:48)
    at scala.sys.package$.env(package.scala:61)
    at scala.tools.nsc.settings.ScalaSettings.defaultClasspath(ScalaSettings.scala:30)
    at scala.tools.nsc.settings.ScalaSettings.defaultClasspath$(ScalaSettings.scala:30)
    at scala.tools.nsc.settings.MutableSettings.defaultClasspath(MutableSettings.scala:19)
    at scala.tools.nsc.settings.ScalaSettings.$init$(ScalaSettings.scala:57)
    at scala.tools.nsc.settings.MutableSettings.<init>(MutableSettings.scala:20)
    at scala.tools.nsc.Settings.<init>(Settings.scala:12)
    at scala.tools.nsc.Driver.process(Driver.scala:41)
    at scala.tools.nsc.Main.process(Main.scala)
    ... 34 more
like image 785
Yann Moisan Avatar asked Jan 03 '17 11:01

Yann Moisan


People also ask

How to configure Scala library in IntelliJ?

To install Scala plugin, press Ctrl+Alt+S , open the Plugins page, browse repositories to locate the Scala plugin, click Install and restart IntelliJ IDEA. Now you can successfully check out from VCS, create, or import Scala projects.

Why Scala class is not showing in IntelliJ?

On the Project pane on the left, right-click src and select New => Scala class. If you don't see Scala class, right-click on HelloWorld and click on Add Framework Support…, select Scala and proceed. If you see Error: library is not specified, you can either click download button, or select the library path manually.

How to open Scala class in IntelliJ?

In the Project tool window, right-click a Scala library class that you want to decompile. From the context menu, select Decompile Scala to Java. IntelliJ IDEA converts code to Java and opens the converted file in the editor. You can also open the library class in the editor and use its context menu for the conversion.

How do I change the Scala version in IntelliJ?

 In most cases your project JDK is not compatible with Scala or sbt version, try to change the Scala Compile Server SDK. Press Ctrl+Alt+S to open Settings/Preferences dialog. From the options on the left, select Build, Execution, Deployment | Compiler | Scala | Scala Compiler Server.


2 Answers

This question puts me on the way

so I check the JDK version and surprisingly IntelliJ and Nailgun didn't run with the same JDK.

~ ❯❯❯ ps -ef | grep java
  501  2290  2017   0  4:12PM ??         0:01.81 /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/bin/java … org.jetbrains.plugins.scala.nailgun.NailgunRunner 3200 6a73f540-1a80-476d-96d2-83ab8faaad95
  501  2291  2017   0  4:12PM ??         0:02.15 /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/bin/java …

So I searched in the IntelliJ preferences and found out that Scala Compile Server was configured with an old JDK : 1.8.0_11. Bim !

I've just unchecked the checkbox Use external compile server

like image 173
Yann Moisan Avatar answered Oct 07 '22 17:10

Yann Moisan


go to editconfiguration in intellij and choose in JRE drop down the jdk version which is installed in your system. and do rebuild, It worked for me.

like image 22
Rahul Singh Avatar answered Oct 07 '22 18:10

Rahul Singh