[GRADLE-3371] Gradle Scala Zinc compiler daemon sporadically fails to start Created: 09/Dec/15 Updated: 23/Dec/15 Resolved: 23/Dec/15 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | 2.11-rc-1 |
Type: | Bug | ||
Reporter: | Lari Hotari | Assignee: | Gary Hale |
Resolution: | Fixed | Votes: | 0 |
Description |
Gradle Scala Zinc compiler daemon sporadically fails to start and fails with NoClassDefFoundError or ClassNotFoundException. example of NoClassDefFoundError failure Caused by: java.lang.NoClassDefFoundError: xsbt/Analyzer$ at xsbt.CachedCompiler0$Compiler$sbtAnalyzer$.<init>(CompilerInterface.scala:158) at xsbt.CachedCompiler0$Compiler.sbtAnalyzer$lzycompute(CompilerInterface.scala:156) at xsbt.CachedCompiler0$Compiler.sbtAnalyzer(CompilerInterface.scala:156) at xsbt.CachedCompiler0$Compiler.phaseDescriptors$lzycompute(CompilerInterface.scala:207) at xsbt.CachedCompiler0$Compiler.phaseDescriptors(CompilerInterface.scala:205) at scala.tools.nsc.Global$Run.<init>(Global.scala:1075) at xsbt.CachedCompiler0$$anon$2.<init>(CompilerInterface.scala:106) at xsbt.CachedCompiler0.run(CompilerInterface.scala:106) at xsbt.CachedCompiler0.run(CompilerInterface.scala:95) at xsbt.CompilerInterface.run(CompilerInterface.scala:26) 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 sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:97) at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:97) at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:97) at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:162) at sbt.compiler.AggressiveCompile$$anonfun$3.compileScala$1(AggressiveCompile.scala:96) at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:139) at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:86) at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:38) at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:36) at sbt.inc.IncrementalCommon.cycle(IncrementalCommon.scala:31) at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:39) at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:38) at sbt.inc.Incremental$.manageClassfiles(Incremental.scala:66) at sbt.inc.Incremental$.compile(Incremental.scala:38) at sbt.inc.IncrementalCompile$.apply(Compile.scala:26) at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:153) at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:70) at com.typesafe.zinc.Compiler.compile(Compiler.scala:201) at com.typesafe.zinc.Compiler.compile(Compiler.scala:183) at com.typesafe.zinc.Compiler.compile(Compiler.scala:174) at com.typesafe.zinc.Compiler.compile(Compiler.scala:165) at org.gradle.api.internal.tasks.scala.ZincScalaCompiler$Compiler.execute(ZincScalaCompiler.java:69) at org.gradle.api.internal.tasks.scala.ZincScalaCompiler.execute(ZincScalaCompiler.java:48) at org.gradle.api.internal.tasks.scala.ZincScalaCompiler.execute(ZincScalaCompiler.java:37) at org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonServer.execute(CompilerDaemonServer.java:74) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) example of ClassNotFoundException failure Caused by: java.lang.ClassNotFoundException: xsbt.CompilerInterface at sbt.compiler.AnalyzingCompiler.getInterfaceClass(AnalyzingCompiler.scala:117) at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:98) at sbt.compiler.AnalyzingCompiler.newCachedCompiler(AnalyzingCompiler.scala:56) at sbt.compiler.AnalyzingCompiler.newCachedCompiler(AnalyzingCompiler.scala:51) at sbt.compiler.CompilerCache$$anon$2.apply(CompilerCache.scala:47) at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:39) at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:97) at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:97) at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:97) at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:162) at sbt.compiler.AggressiveCompile$$anonfun$3.compileScala$1(AggressiveCompile.scala:96) at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:139) at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:86) at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:38) at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:36) at sbt.inc.IncrementalCommon.cycle(IncrementalCommon.scala:31) at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:39) at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:38) at sbt.inc.Incremental$.manageClassfiles(Incremental.scala:66) at sbt.inc.Incremental$.compile(Incremental.scala:38) at sbt.inc.IncrementalCompile$.apply(Compile.scala:26) at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:153) at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:70) at com.typesafe.zinc.Compiler.compile(Compiler.scala:201) at com.typesafe.zinc.Compiler.compile(Compiler.scala:183) at com.typesafe.zinc.Compiler.compile(Compiler.scala:174) at com.typesafe.zinc.Compiler.compile(Compiler.scala:165) at org.gradle.api.internal.tasks.scala.ZincScalaCompiler$Compiler.execute(ZincScalaCompiler.java:69) at org.gradle.api.internal.tasks.scala.ZincScalaCompiler.execute(ZincScalaCompiler.java:48) at org.gradle.api.internal.tasks.scala.ZincScalaCompiler.execute(ZincScalaCompiler.java:37) at org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonServer.execute(CompilerDaemonServer.java:53) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) |
Comments |
Comment by Gary Hale [ 23/Dec/15 ] |
The zinc compiler generates a compiler-interface.jar in the zinc cache directory whenever it does not exist. If multiple compilers are run simultaneously (either via parallel execution or just multiple independent builds) there is a race condition where one of them can try to start using the file while another is creating it, or multiple compilers can try to create it. If the compiler-interface.jar already exists, then this issue doesn't arise, so it's most common when running for the first time or when the scala/java version(s) change. This has been fixed by setting the Zinc cache dir to a location under GRADLE_USER_HOME and synchronizing the creation of Zinc compilers across all processes running as the same user. Thus, only one compiler will create the jar and the others will block until it has been fully created. |