We recently started intermittently getting `java.l...
# community-support
l
We recently started intermittently getting
java.lang.ClassNotFoundException: <http://worker.org|worker.org>.gradle.process.internal.worker.GradleWorkerMain
errors in our CI pipelines. (more details in thread) We're not sure what's causing it, however... • it looks like wiping the cache "fixes" the problem. • once the problem shows up in a CI pipeline, that pipeline will continue to fail if we rerun it without wiping its cache. We don't want to completely eliminate the cache, as wiping the cache makes our CI builds much slower. We've had this cache setup for about 9 months now, but this issue first started showing up a few days ago.
More detailed error output. Note that the task that fails varies. In this one it's
:runKtlintCheckOverKotlinScripts
, but other times it has been other tasks.
Copy code
Error: Could not find or load main class worker.org.gradle.process.internal.worker.GradleWorkerMain
Caused by: java.lang.ClassNotFoundException: worker.org.gradle.process.internal.worker.GradleWorkerMain
Error: Could not find or load main class worker.org.gradle.process.internal.worker.GradleWorkerMain
Caused by: java.lang.ClassNotFoundException: worker.org.gradle.process.internal.worker.GradleWorkerMain
Could not write standard input to Gradle Worker Daemon 2.
java.io.IOException: Broken pipe
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(FileOutputStream.java:367)
	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:125)
	at java.base/java.io.BufferedOutputStream.implFlush(BufferedOutputStream.java:252)
	at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:246)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.writeBuffer(ExecOutputHandleRunner.java:98)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.forwardContent(ExecOutputHandleRunner.java:85)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:64)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Could not write standard input to Gradle Worker Daemon 1.
java.io.IOException: Broken pipe
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(FileOutputStream.java:367)
	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:125)
	at java.base/java.io.BufferedOutputStream.implFlush(BufferedOutputStream.java:252)
	at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:246)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.writeBuffer(ExecOutputHandleRunner.java:98)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.forwardContent(ExecOutputHandleRunner.java:85)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:64)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
...

Error: Could not find or load main class worker.org.gradle.process.internal.worker.GradleWorkerMain
Caused by: java.lang.ClassNotFoundException: worker.org.gradle.process.internal.worker.GradleWorkerMain
Could not write standard input to Gradle Worker Daemon 3.
java.io.IOException: Broken pipe
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(FileOutputStream.java:367)
	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:125)
	at java.base/java.io.BufferedOutputStream.implFlush(BufferedOutputStream.java:252)
	at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:246)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.writeBuffer(ExecOutputHandleRunner.java:98)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.forwardContent(ExecOutputHandleRunner.java:85)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:64)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
FAILURE: Build completed with 3 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':buildSrc:runKtlintCheckOverMainSourceSet'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
   > Failed to run Gradle Worker Daemon
      > Process 'Gradle Worker Daemon 2' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':buildSrc:runKtlintCheckOverKotlinScripts'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
   > Failed to run Gradle Worker Daemon
      > Process 'Gradle Worker Daemon 1' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
==============================================================================
3: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':runKtlintCheckOverKotlinScripts'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
   > Failed to run Gradle Worker Daemon
      > Process 'Gradle Worker Daemon 3' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
j
Your worker daemons are crashing. Could you please check in your
$gradlehome/daemon/*/daemon-*.out.log
if there are more details about the cause of the crashes? You may also have to try building with
--debug
to get more details. Could you also mention which version of Gradle you are using?
l
Thanks! I'll take a look at the
$gradlehome/daemon/*/daemon-*.out.log
. (As it's in CI, it'll take me a bit of time to get that info,) Here's the version info:
Copy code
./gradlew --version
------------------------------------------------------------
Gradle 8.5
------------------------------------------------------------
Build time:   2023-11-29 14:08:57 UTC
Revision:     28aca86a7180baa17117e0e5ba01d8ea9feca598
Kotlin:       1.9.20
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          21.0.5 (Eclipse Adoptium 21.0.5+11-LTS)
OS:           Linux 5.15.154+ amd64
I'm still having that issue with getting
java.lang.ClassNotFoundException: <http://worker.org|worker.org>.gradle.process.internal.worker.GradleWorkerMain
errors in our CI pipelines. (more details in thread)
Sorry it took me several days to get back with this. I've had a bad cold recently. Below is the relevant part of the
daemon-*.out.log
. There's nothing that looks suspicious to us before this point in the log.
Copy code
2025-01-23T02:31:21.399+0000 [DEBUG] [org.jetbrains.kotlin.gradle.internal.ClassLoadersCachingBuildService$Inject] Creating a new classloader for classpath [/builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-build-tools-impl/2.1.0/a8f65725498c49ddc384d7107c3fd937c248d28d/kotlin-build-tools-impl-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-build-tools-api/2.1.0/e6c176cdaeb5ce3751c120eb1dfd84e5cc64d369/kotlin-build-tools-api-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-runner/2.1.0/aeff856eff94e2ca0582f155b414a57cc7837e07/kotlin-compiler-runner-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-embeddable/2.1.0/988bf980588bbbcfa1ba19c1ffd7aa869b335a31/kotlin-compiler-embeddable-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-compiler-embeddable/2.1.0/8bd8465d1e4f3c8d21f45682a09a0aade50c044a/kotlin-scripting-compiler-embeddable-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-compiler-impl-embeddable/2.1.0/95349696c9ef4080bb9e72c3419e1f8eeeea6eac/kotlin-scripting-compiler-impl-embeddable-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-daemon-client/2.1.0/2c219a5026f6c4c1188b40cb3b6bb557f16182b7/kotlin-daemon-client-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/2.1.0/63671ebf34dac00ac97885f3e0e6f7478537bd20/kotlin-scripting-jvm-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/2.1.0/269ce38f2d7214d4608059b4326b1710f82b91b9/kotlin-scripting-common-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.1.0/85f8b81009cda5890e54ba67d64b5e599c645020/kotlin-stdlib-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/2.1.0/5909da8c57b75a117714ab0e348c86101b7a3284/kotlin-script-runtime-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.6.10/1cbe9c92c12a94eea200d23c2bbaedaf3daf5132/kotlin-reflect-1.6.10.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-daemon-embeddable/2.1.0/420bae1908e4a353f5b56c3c850d24d86367b25d/kotlin-daemon-embeddable-2.1.0.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.deps/trove4j/1.0.20200330/3afb14d5f9ceb459d724e907a21145e8ff394f02/trove4j-1.0.20200330.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-jvm/1.6.4/2c997cd1c0ef33f3e751d3831929aeff1390cb30/kotlinx-coroutines-core-jvm-1.6.4.jar, /builds/my/project/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-build-common/2.1.0/a8406c9517978a8b7127b95882b0bcd674be317b/kotlin-build-common-2.1.0.jar]
2025-01-23T02:31:22.089+0000 [ERROR] [system.err] Error: Could not find or load main class worker.org.gradle.process.internal.worker.GradleWorkerMain
2025-01-23T02:31:22.089+0000 [ERROR] [system.err] Caused by: java.lang.ClassNotFoundException: worker.org.gradle.process.internal.worker.GradleWorkerMain
2025-01-23T02:31:22.108+0000 [ERROR] [system.err] Error: Could not find or load main class worker.org.gradle.process.internal.worker.GradleWorkerMain
2025-01-23T02:31:22.108+0000 [ERROR] [system.err] Caused by: java.lang.ClassNotFoundException: worker.org.gradle.process.internal.worker.GradleWorkerMain
2025-01-23T02:31:22.119+0000 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(6)-127.0.0.1: accepted socket from [127.0.0.1:58282]
2025-01-23T02:31:22.120+0000 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(6)-127.0.0.1: (port 33737) op = 80
2025-01-23T02:31:22.120+0000 [DEBUG] [sun.rmi.loader] RMI TCP Connection(6)-127.0.0.1: name = "[Ljava.rmi.server.ObjID;", codebase = "", defaultLoader = jdk.internal.loader.ClassLoaders$PlatformClassLoader@714a3b4f
2025-01-23T02:31:22.120+0000 [DEBUG] [sun.rmi.loader] RMI TCP Connection(6)-127.0.0.1: name = "java.rmi.server.ObjID", codebase = "", defaultLoader = jdk.internal.loader.ClassLoaders$PlatformClassLoader@714a3b4f
2025-01-23T02:31:22.121+0000 [DEBUG] [sun.rmi.loader] RMI TCP Connection(6)-127.0.0.1: name = "java.rmi.server.UID", codebase = "", defaultLoader = jdk.internal.loader.ClassLoaders$PlatformClassLoader@714a3b4f
2025-01-23T02:31:22.121+0000 [DEBUG] [sun.rmi.loader] RMI TCP Connection(6)-127.0.0.1: name = "java.rmi.dgc.VMID", codebase = "", defaultLoader = jdk.internal.loader.ClassLoaders$PlatformClassLoader@714a3b4f
2025-01-23T02:31:22.121+0000 [DEBUG] [sun.rmi.loader] RMI TCP Connection(6)-127.0.0.1: name = "[B", codebase = "", defaultLoader = jdk.internal.loader.ClassLoaders$PlatformClassLoader@714a3b4f
2025-01-23T02:31:22.138+0000 [ERROR] [org.gradle.process.internal.streams.ExecOutputHandleRunner] Could not write standard input to Gradle Worker Daemon 2.
java.io.IOException: Broken pipe
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(FileOutputStream.java:367)
	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:125)
	at java.base/java.io.BufferedOutputStream.implFlush(BufferedOutputStream.java:252)
	at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:246)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.writeBuffer(ExecOutputHandleRunner.java:98)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.forwardContent(ExecOutputHandleRunner.java:85)
	at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:64)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
2025-01-23T02:31:22.140+0000 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
2025-01-23T02:31:22.140+0000 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'Gradle Worker Daemon 2' finished with exit value 1 (state: FAILED)
One thing we've found is that erasing
.gradle/caches/
seems to prevent this problem, but obviously has a performance penalty. We've had the same caching setup, and have been using the same version of Gradle, for months, but this problem started less than 2 weeks ago. There was a recent GitLab update shortly before the problem started happening, but there's nothing in their release notes related to caching (we're using GitLab's CI cache to cache Gradle's caches).
j
Maybe compare that last
[DEBUG] [org.jetbrains.kotlin.gradle.internal.ClassLoadersCachingBuildService$Inject] Creating a new classloader for classpath
log entry with the one of a build that works to see if there is any unexpected classpath change.
Then if they are the same, I would check if all these
*.jar
are still present and readable when the build fails, and if their checksums match those of build that works, to rule out cache corruption. Also maybe you could try deleting only
.gradle/caches/modules-2
to see if that makes the build work again.