Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected NoClassDefFoundError when compiling the bridge #743

Closed
ouchxp opened this issue Nov 28, 2018 · 13 comments · Fixed by #747
Closed

Unexpected NoClassDefFoundError when compiling the bridge #743

ouchxp opened this issue Nov 28, 2018 · 13 comments · Fixed by #747
Labels
bug A defect or misbehaviour. task / compile under investigation Any PR or ticket that requires investigation before further labelling or finding it actionable.

Comments

@ouchxp
Copy link

ouchxp commented Nov 28, 2018

I'm getting NoClassDefFoundError: javax/tools/DiagnosticListener when running 2.11 project. However if I switch to 2.12, everything works just fine.

 ~/I/scalatest> bloop about
    Bloop-frontend version    `1.0.0`
    Zinc version     `1.1.7+62-0f4ad9d5`
    Scala version    `2.12.6`
~> scala
Welcome to Scala 2.11.12 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_192).
 ~/I/scalatest> bloop run garyscalatest
Compiling 1 Scala source to /Users/drwho/garyscalatest/.bloop/scalatest/scala-2.11/classes ...
Non-compiled module 'compiler-bridge_2.11' for Scala 2.11.12. Compiling...
error: java.lang.NoClassDefFoundError: javax/tools/DiagnosticListener
        at scala.tools.util.PathResolverBase$Calculated$.javaBootClasspath(PathResolver.scala:277)
        at scala.tools.util.PathResolverBase$Calculated$.basis(PathResolver.scala:283)
        at scala.tools.util.PathResolverBase$Calculated$.containers$lzycompute(PathResolver.scala:293)
        at scala.tools.util.PathResolverBase$Calculated$.containers(PathResolver.scala:293)
        at scala.tools.util.PathResolverBase.containers(PathResolver.scala:309)
        at scala.tools.util.PathResolver.computeResult(PathResolver.scala:341)
        at scala.tools.util.PathResolver.computeResult(PathResolver.scala:332)
        at scala.tools.util.PathResolverBase.result(PathResolver.scala:314)
        at scala.tools.nsc.backend.JavaPlatform$class.classPath(JavaPlatform.scala:28)
        at scala.tools.nsc.Global$GlobalPlatform.classPath(Global.scala:115)
        at scala.tools.nsc.Global.scala$tools$nsc$Global$$recursiveClassPath(Global.scala:131)
        at scala.tools.nsc.Global$GlobalMirror.rootLoader(Global.scala:64)
        at scala.reflect.internal.Mirrors$Roots$RootClass.<init>(Mirrors.scala:307)
        at scala.reflect.internal.Mirrors$Roots.RootClass$lzycompute(Mirrors.scala:321)
        at scala.reflect.internal.Mirrors$Roots.RootClass(Mirrors.scala:321)
        at scala.reflect.internal.Mirrors$Roots$EmptyPackageClass.<init>(Mirrors.scala:330)
        at scala.reflect.internal.Mirrors$Roots.EmptyPackageClass$lzycompute(Mirrors.scala:336)
        at scala.reflect.internal.Mirrors$Roots.EmptyPackageClass(Mirrors.scala:336)
        at scala.reflect.internal.Mirrors$Roots.EmptyPackageClass(Mirrors.scala:276)
        at scala.reflect.internal.Mirrors$RootsBase.init(Mirrors.scala:250)
        at scala.tools.nsc.Global.rootMirror$lzycompute(Global.scala:73)
        at scala.tools.nsc.Global.rootMirror(Global.scala:71)
        at scala.tools.nsc.Global.rootMirror(Global.scala:39)
        at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass$lzycompute(Definitions.scala:257)
        at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:257)
        at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1390)
        at scala.tools.nsc.Global$Run.<init>(Global.scala:1242)
        at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
        at scala.tools.nsc.MainClass.doCompile(Main.scala:23)
        at scala.tools.nsc.Driver.process(Driver.scala:51)
        at scala.tools.nsc.Main.process(Main.scala)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at sbt.internal.inc.RawCompiler.getReporter$1(RawCompiler.scala:50)
        at sbt.internal.inc.RawCompiler.apply(RawCompiler.scala:71)
        at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$6(AnalyzingCompiler.scala:354)
        at sbt.internal.inc.AnalyzingCompiler$.handleCompilationError$1(AnalyzingCompiler.scala:331)
        at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$4(AnalyzingCompiler.scala:350)
        at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$4$adapted(AnalyzingCompiler.scala:345)
        at sbt.io.IO$.withTemporaryDirectory(IO.scala:376)
        at sbt.io.IO$.withTemporaryDirectory(IO.scala:383)
        at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$2(AnalyzingCompiler.scala:345)
        at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$2$adapted(AnalyzingCompiler.scala:339)
        at sbt.io.IO$.withTemporaryDirectory(IO.scala:376)
        at sbt.io.IO$.withTemporaryDirectory(IO.scala:383)
        at sbt.internal.inc.AnalyzingCompiler$.compileSources(AnalyzingCompiler.scala:339)
        at sbt.internal.inc.ZincComponentCompiler.$anonfun$compileAndInstall$3(ZincComponentCompiler.scala:279)
        at sbt.internal.inc.ZincComponentCompiler.$anonfun$compileAndInstall$3$adapted(ZincComponentCompiler.scala:264)
        at sbt.io.IO$.withTemporaryDirectory(IO.scala:376)
        at sbt.io.IO$.withTemporaryDirectory(IO.scala:383)
        at sbt.internal.inc.ZincComponentCompiler.$anonfun$compileAndInstall$2(ZincComponentCompiler.scala:264)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at sbt.internal.util.BufferedLogger.bufferQuietly(BufferedLogger.scala:106)
        at sbt.internal.inc.ZincComponentCompiler.$anonfun$compileAndInstall$1(ZincComponentCompiler.scala:264)
        at sbt.internal.inc.ZincComponentCompiler.$anonfun$compileAndInstall$1$adapted(ZincComponentCompiler.scala:261)
        at sbt.io.IO$.withTemporaryDirectory(IO.scala:376)
        at sbt.io.IO$.withTemporaryDirectory(IO.scala:383)
        at sbt.internal.inc.ZincComponentCompiler.compileAndInstall(ZincComponentCompiler.scala:261)
        at sbt.internal.inc.ZincComponentCompiler.$anonfun$compiledBridgeJar$1(ZincComponentCompiler.scala:227)
        at sbt.internal.inc.IfMissing$Define.run(IfMissing.scala:19)
        at sbt.internal.inc.ZincComponentManager.createAndCache$1(ZincComponentManager.scala:46)
        at sbt.internal.inc.ZincComponentManager.$anonfun$files$3(ZincComponentManager.scala:57)
        at sbt.internal.inc.ZincComponentManager.getOrElse$1(ZincComponentManager.scala:38)
        at sbt.internal.inc.ZincComponentManager.$anonfun$files$2(ZincComponentManager.scala:57)
        at sbt.internal.inc.ZincComponentManager$$anon$1.call(ZincComponentManager.scala:87)
        at bloop.BloopComponentsLock$.apply(BloopComponentsLock.scala:9)
        at sbt.internal.inc.ZincComponentManager.lock(ZincComponentManager.scala:87)
        at sbt.internal.inc.ZincComponentManager.$anonfun$lockSecondaryCache$1(ZincComponentManager.scala:84)
        at scala.Option.map(Option.scala:146)
        at sbt.internal.inc.ZincComponentManager.lockSecondaryCache(ZincComponentManager.scala:82)
        at sbt.internal.inc.ZincComponentManager.fromSecondary$1(ZincComponentManager.scala:55)
        at sbt.internal.inc.ZincComponentManager.$anonfun$files$6(ZincComponentManager.scala:61)
        at sbt.internal.inc.ZincComponentManager.getOrElse$1(ZincComponentManager.scala:38)
        at sbt.internal.inc.ZincComponentManager.$anonfun$files$5(ZincComponentManager.scala:61)
        at sbt.internal.inc.ZincComponentManager$$anon$1.call(ZincComponentManager.scala:87)
        at bloop.BloopComponentsLock$.apply(BloopComponentsLock.scala:9)
        at sbt.internal.inc.ZincComponentManager.lock(ZincComponentManager.scala:87)
        at sbt.internal.inc.ZincComponentManager.lockLocalCache(ZincComponentManager.scala:78)
        at sbt.internal.inc.ZincComponentManager.files(ZincComponentManager.scala:61)
        at sbt.internal.inc.ZincComponentManager.file(ZincComponentManager.scala:66)
        at sbt.internal.inc.ZincComponentCompiler.compiledBridgeJar(ZincComponentCompiler.scala:227)
        at sbt.internal.inc.ZincComponentCompiler$ZincCompilerBridgeProvider.compiledBridge(ZincComponentCompiler.scala:84)
        at sbt.internal.inc.ZincComponentCompiler$ZincCompilerBridgeProvider.fetchCompiledBridge(ZincComponentCompiler.scala:91)
        at sbt.internal.inc.AnalyzingCompiler.loader(AnalyzingCompiler.scala:253)
        at sbt.internal.inc.AnalyzingCompiler.getInterfaceClass(AnalyzingCompiler.scala:271)
        at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:238)
        at sbt.internal.inc.AnalyzingCompiler.newCachedCompiler(AnalyzingCompiler.scala:133)
        at sbt.internal.inc.AnalyzingCompiler.newCachedCompiler(AnalyzingCompiler.scala:120)
        at sbt.internal.inc.FreshCompilerCache.apply(CompilerCache.scala:78)
        at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:87)
        at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:83)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:134)
        at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:74)
        at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:117)
        at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:310)
        at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:310)
        at sbt.internal.inc.Incremental$.doCompile(Incremental.scala:106)
        at sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:87)
        at sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:116)
        at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:63)
        at sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:89)
        at sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:134)
        at sbt.internal.inc.Incremental$.compile(Incremental.scala:80)
        at sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:67)
        at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:314)
        at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:272)
        at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:161)
        at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:241)
        at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:69)
        at bloop.Compiler$.compile(Compiler.scala:98)
        at bloop.engine.tasks.Tasks$.compile$1(Tasks.scala:103)
        at bloop.engine.tasks.Tasks$.$anonfun$compile$3(Tasks.scala:115)
        at bloop.engine.tasks.Tasks$.$anonfun$toCompileTask$1(Tasks.scala:174)
        at monix.eval.internal.TaskRunLoop$.monix$eval$internal$TaskRunLoop$$loop$1(TaskRunLoop.scala:187)
        at monix.eval.internal.TaskRunLoop$RestartCallback$1.onSuccess(TaskRunLoop.scala:119)
        at monix.eval.Task$.$anonfun$forkedUnit$2(Task.scala:1463)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: javax.tools.DiagnosticListener
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 122 more
Attempting to fetch ch.epfl.scala:compiler-bridge_2.11:1.1.7+62-0f4ad9d5.
[E] ## Exception when compiling 1 sources to /Users/nanw/IdeaProjects/garyscalatest/.bloop/garyscalatest/scala-2.11/classes
[E] null
[E] java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[E] java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[E] java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[E] java.base/java.lang.reflect.Method.invoke(Method.java:566)
[E] sbt.internal.inc.RawCompiler.getReporter$1(RawCompiler.scala:50)
[E] sbt.internal.inc.RawCompiler.apply(RawCompiler.scala:71)
[E] sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$6(AnalyzingCompiler.scala:354)
[E] sbt.internal.inc.AnalyzingCompiler$.handleCompilationError$1(AnalyzingCompiler.scala:331)
[E] sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$4(AnalyzingCompiler.scala:350)
[E] sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$4$adapted(AnalyzingCompiler.scala:345)
[E] sbt.io.IO$.withTemporaryDirectory(IO.scala:376)
[E] sbt.io.IO$.withTemporaryDirectory(IO.scala:383)
[E] sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$2(AnalyzingCompiler.scala:345)
[E] sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$2$adapted(AnalyzingCompiler.scala:339)
[E] sbt.io.IO$.withTemporaryDirectory(IO.scala:376)
[E] sbt.io.IO$.withTemporaryDirectory(IO.scala:383)
[E] sbt.internal.inc.AnalyzingCompiler$.compileSources(AnalyzingCompiler.scala:339)
[E] sbt.internal.inc.ZincComponentCompiler.$anonfun$compileAndInstall$3(ZincComponentCompiler.scala:279)
[E] sbt.internal.inc.ZincComponentCompiler.$anonfun$compileAndInstall$3$adapted(ZincComponentCompiler.scala:264)
[E] sbt.io.IO$.withTemporaryDirectory(IO.scala:376)
[E] sbt.io.IO$.withTemporaryDirectory(IO.scala:383)
[E] sbt.internal.inc.ZincComponentCompiler.$anonfun$compileAndInstall$2(ZincComponentCompiler.scala:264)
[E] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[E] sbt.internal.util.BufferedLogger.bufferQuietly(BufferedLogger.scala:106)
[E] sbt.internal.inc.ZincComponentCompiler.$anonfun$compileAndInstall$1(ZincComponentCompiler.scala:264)
[E] sbt.internal.inc.ZincComponentCompiler.$anonfun$compileAndInstall$1$adapted(ZincComponentCompiler.scala:261)
[E] sbt.io.IO$.withTemporaryDirectory(IO.scala:376)
[E] sbt.io.IO$.withTemporaryDirectory(IO.scala:383)
[E] sbt.internal.inc.ZincComponentCompiler.compileAndInstall(ZincComponentCompiler.scala:261)
[E] sbt.internal.inc.ZincComponentCompiler.$anonfun$compiledBridgeJar$1(ZincComponentCompiler.scala:227)
[E] sbt.internal.inc.IfMissing$Define.run(IfMissing.scala:19)
[E] sbt.internal.inc.ZincComponentManager.createAndCache$1(ZincComponentManager.scala:46)
[E] sbt.internal.inc.ZincComponentManager.$anonfun$files$3(ZincComponentManager.scala:57)
[E] sbt.internal.inc.ZincComponentManager.getOrElse$1(ZincComponentManager.scala:38)
[E] sbt.internal.inc.ZincComponentManager.$anonfun$files$2(ZincComponentManager.scala:57)
[E] sbt.internal.inc.ZincComponentManager$$anon$1.call(ZincComponentManager.scala:87)
[E] bloop.BloopComponentsLock$.apply(BloopComponentsLock.scala:9)
[E] sbt.internal.inc.ZincComponentManager.lock(ZincComponentManager.scala:87)
[E] sbt.internal.inc.ZincComponentManager.$anonfun$lockSecondaryCache$1(ZincComponentManager.scala:84)
[E] scala.Option.map(Option.scala:146)
[E] sbt.internal.inc.ZincComponentManager.lockSecondaryCache(ZincComponentManager.scala:82)
[E] sbt.internal.inc.ZincComponentManager.fromSecondary$1(ZincComponentManager.scala:55)
[E] sbt.internal.inc.ZincComponentManager.$anonfun$files$6(ZincComponentManager.scala:61)
[E] sbt.internal.inc.ZincComponentManager.getOrElse$1(ZincComponentManager.scala:38)
[E] sbt.internal.inc.ZincComponentManager.$anonfun$files$5(ZincComponentManager.scala:61)
[E] sbt.internal.inc.ZincComponentManager$$anon$1.call(ZincComponentManager.scala:87)
[E] bloop.BloopComponentsLock$.apply(BloopComponentsLock.scala:9)
[E] sbt.internal.inc.ZincComponentManager.lock(ZincComponentManager.scala:87)
[E] sbt.internal.inc.ZincComponentManager.lockLocalCache(ZincComponentManager.scala:78)
[E] sbt.internal.inc.ZincComponentManager.files(ZincComponentManager.scala:61)
[E] sbt.internal.inc.ZincComponentManager.file(ZincComponentManager.scala:66)
[E] sbt.internal.inc.ZincComponentCompiler.compiledBridgeJar(ZincComponentCompiler.scala:227)
[E] sbt.internal.inc.ZincComponentCompiler$ZincCompilerBridgeProvider.compiledBridge(ZincComponentCompiler.scala:84)
[E] sbt.internal.inc.ZincComponentCompiler$ZincCompilerBridgeProvider.fetchCompiledBridge(ZincComponentCompiler.scala:91)
[E] sbt.internal.inc.AnalyzingCompiler.loader(AnalyzingCompiler.scala:253)
[E] sbt.internal.inc.AnalyzingCompiler.getInterfaceClass(AnalyzingCompiler.scala:271)
[E] sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:238)
[E] sbt.internal.inc.AnalyzingCompiler.newCachedCompiler(AnalyzingCompiler.scala:133)
[E] sbt.internal.inc.AnalyzingCompiler.newCachedCompiler(AnalyzingCompiler.scala:120)
[E] sbt.internal.inc.FreshCompilerCache.apply(CompilerCache.scala:78)
[E] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:87)
[E] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:83)
[E] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[E] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:134)
[E] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:74)
[E] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:117)
[E] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:310)
[E] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:310)
[E] sbt.internal.inc.Incremental$.doCompile(Incremental.scala:106)
[E] sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:87)
[E] sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:116)
[E] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:63)
[E] sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:89)
[E] sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:134)
[E] sbt.internal.inc.Incremental$.compile(Incremental.scala:80)
[E] sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:67)
[E] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:314)
[E] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:272)
[E] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:161)
[E] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:241)
[E] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:69)
[E] bloop.Compiler$.compile(Compiler.scala:98)
[E] bloop.engine.tasks.Tasks$.compile$1(Tasks.scala:103)
[E] bloop.engine.tasks.Tasks$.$anonfun$compile$3(Tasks.scala:115)
[E] bloop.engine.tasks.Tasks$.$anonfun$toCompileTask$1(Tasks.scala:174)
[E] monix.eval.internal.TaskRunLoop$.monix$eval$internal$TaskRunLoop$$loop$1(TaskRunLoop.scala:187)
[E] monix.eval.internal.TaskRunLoop$RestartCallback$1.onSuccess(TaskRunLoop.scala:119)
[E] monix.eval.Task$.$anonfun$forkedUnit$2(Task.scala:1463)
[E] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[E] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[E] java.base/java.lang.Thread.run(Thread.java:834)
[E]  
@jvican
Copy link
Contributor

jvican commented Nov 28, 2018

Looks related to scala/bug#10603 and scala/bug#11154, which happen when higher versions of Java 8 are used. It's not clear to me this is bloop's fault.

  1. Do you happen to have both Java 8 and 9 installed in the same machine? In the past some people have had problems because the scala in the terminal runs with Java 8 but the bloop server via brew services runs with Java 9 or higher. Please make sure this is not the case (sometimes uninstalling other jvm versions help a lot when debugging these issues)
  2. Can you try by passing -nobootcp as a scalac option of the project?

The error here happens when compiling the bridge, so you should be able to reproduce by just compiling the project.

@jvican jvican changed the title NoClassDefFoundError: javax/tools/DiagnosticListener when running 2.11 project Unexpected NoClassDefFoundError when compiling the bridge Nov 28, 2018
@jvican jvican added bug A defect or misbehaviour. task / compile under investigation Any PR or ticket that requires investigation before further labelling or finding it actionable. labels Nov 28, 2018
@ouchxp
Copy link
Author

ouchxp commented Nov 28, 2018

Thanks @jvican uninstalling my Java11 does solve the problem.
However I have checked both before and after installing Java11, the bloop server is indeed running with Java8, perhaps there are some separate JVM instance created by bloop server is running with Java11, even with setting the Java8 to be system default.
Addition to that, is there anyway I can specify bloop to always use another Java8? since I'd like to keep Java11 for other projects.

@jvican
Copy link
Contributor

jvican commented Nov 29, 2018

@ouchxp Bloop does not spawn any new JVM processes, so either this is a mismatch between the configuration of JAVA_HOME and the jvm used (as one of the linked tickets suggested) or the server was really running with Java 11. 😟

I don't know why Mac OSX causes these problems but they are for sure really annoying. I would be grateful if you can find a way to solve this problem and avoid any conflicts with Java 11 installations because, as you say, having Java 11 for other projects is critical for some people.

@ouchxp
Copy link
Author

ouchxp commented Nov 29, 2018

Had a closer look at this issue, The blp-server binary is configured to run with sh, and sh is not taking any profile as a non-login shell, so the JAVA_HOME is empty and I couldn't find a better way to set JAVA_HOME other than modify the plist. blp-server will try run with the system default java binary when JAVA_HOME is empty and on MacOS it always try to use higher version of Java which is Java 11 in my case.

@ouchxp ouchxp closed this as completed Nov 29, 2018
@jvican
Copy link
Contributor

jvican commented Nov 29, 2018

Thanks for the careful investigation @ouchxp. Can you copy paste your change in the plist so that we can add it to our brew installation process?

@ouchxp
Copy link
Author

ouchxp commented Nov 30, 2018

@jvican
What I did is quite simple.
I created a wrapper script called blp-server-wrapper which will set JAVA_HOME and execute the blp-server

#!/usr/bin/env sh
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
exec /usr/local/Cellar/bloop/1.0.0/bin/blp-server "$@"

And then calling the blp-server-wrapper In the plist,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>homebrew.mxcl.bloop</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/Cellar/bloop/1.0.0/bin/blp-server-wrapper</string>
    </array>
    <key>KeepAlive</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/usr/local/Cellar/bloop/1.0.0/log/bloop/bloop.out.log</string>
    <key>StandardErrorPath</key>
    <string>/usr/local/Cellar/bloop/1.0.0/log/bloop/bloop.err.log</string>
</dict>
</plist>

@jvican
Copy link
Contributor

jvican commented Dec 3, 2018

@ouchxp I've dug deeper into this limitation because it's a show-stopper. It all boils down to the fact that brew services uses launchd/launchtl to run the services and their environment variables must be configured manually.

How can the user configure manually the environment variables used by brew services and, concretely, brew services start bloop? Well, there are two viable options:

  1. [recommended] Create launch agent to set environment variables you have in sh, explained here.
  2. via launchctl setenv (dynamic approach, instant but goes away after reboot), explained here

The recommended solution doesn't work when "Reopen windows after reboot" is enabled, so if you're having some problems after reboot I recommend restarting bloop brew services restart bloop so that the bloop's plist is launched after the launch agent setting environment variables.

I wished there was a more straightforward way of telling you how to fix this, but there isn't. Mac OS is making our life difficult here.

These solutions require manual user intervention. A way we could fix this in the future without educating our users is if coursier/coursier#879 sets the JAVA_HOME of the bootstrapped script to the available JAVA_HOME available for the coursier bootstrap invocation. Until then, we'll need to document this in our docs.

Extra references:

  1. https://apple.stackexchange.com/questions/64916/defining-environment-variables-with-launchd-launchctl
  2. https://stackoverflow.com/questions/25385934/setting-environment-variables-via-launchd-conf-no-longer-works-in-os-x-yosemite

@olafurpg
Copy link
Contributor

olafurpg commented Dec 3, 2018

@jvican can the bloop plist hardcode the full Java 8 path?

echo $(/usr/libexec/java_home -v 1.8)/bin/java
/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/bin/java

@jvican
Copy link
Contributor

jvican commented Dec 3, 2018

@olafurpg It would need to be coursier bootstrap the one that hardcodes it (assuming JAVA_HOME is available in the environment where brew runs the installation script, which is not clear at all)

@alexarchambault
Copy link
Contributor

coursier bootstrap could allow to add some code in preamble of bootstraps for that. Or even have an option to add that particular code, that seems general and useful enough.

@olafurpg
Copy link
Contributor

olafurpg commented Dec 3, 2018

You can run coursier launch|fetch|... with custom java path and JVM options.

java -jar coursier fetch org.scalameta:mtags_2.12:0.2.0

The flag -jar coursier points to a slim coursier bootstrap script from https://github.com/coursier/coursier/blob/master/coursier We do this in the Metals VS Code extension.

I agree it would be a nice improvement nevertheless to make coursier bootstrap scripts JAVA_HOME aware.

@alexarchambault
Copy link
Contributor

Yep, as @olafurpg says, you can always run java yourself, and tweak that.

@jvican jvican reopened this Dec 3, 2018
jvican added a commit that referenced this issue Dec 3, 2018
This fix uses the godsend `/usr/libexec/java_home` to detect the java
home for 1.8 and use that one to run `coursier launch` (failing with a
helpful error message if it doesn't find it). The main idea here comes
from the discussion in the bug and some ideas by Olafur (olafurpg).

In reality, this means that the server must be run with Java 1.8 or it
will fail. This is a good compromise for now until we can ensure that
we are as efficient and correct in other Java versions as we're in Java
1.8. I've tested this in my machine where Java 8 is installed via jenv
(which doesn't set the java home variable directly) and Java 11 was
installed via homebrew casks. I believe this scenario stresses this fix
enough to make it valid.

For now, we only use this approach in Mac OS because libexec/java_home
only exist in OSX.

Fixes #743
@jvican
Copy link
Contributor

jvican commented Dec 3, 2018

I re-opened because I found a way to fix this in our installation process so that this doesn't bite future users. This fix doesn't require any user custom configuration and therefore we don't need to educate them about launchd, doing brew services start bloop with a system that has both java 8 and java 11 installed in different ways works like a charm now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A defect or misbehaviour. task / compile under investigation Any PR or ticket that requires investigation before further labelling or finding it actionable.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants