Home > OS >  Failed to exec spawn helper
Failed to exec spawn helper

Time:06-02

When running docker-compose up I get:

------
executor failed running [/bin/sh -c gradle shadowJar]: exit code: 1
ERROR: Service 'slack_bot' failed to build : Build failed

Then I tried running Gradle with --info and it mentions an exception in Gradle:

#11 4.123 An attempt to start the daemon took 0.107 secs.
#11 4.144 
#11 4.144 FAILURE: Build failed with an exception.
#11 4.145 
#11 4.145 * What went wrong:
#11 4.146 A problem occurred starting process 'Gradle build daemon'

Then I run it with --stacktrace to get the exception details:

#11 4.163 Starting a Gradle Daemon (subsequent builds will be faster)
#11 4.407 
#11 4.407 FAILURE: Build failed with an exception.
#11 4.407 
#11 4.408 * What went wrong:
#11 4.408 A problem occurred starting process 'Gradle build daemon'
#11 4.408 
#11 4.408 * Try:
#11 4.408 > Run with --info or --debug option to get more log output.
#11 4.408 > Run with --scan to get full insights.
#11 4.409 
#11 4.409 * Exception is:
#11 4.409 org.gradle.process.internal.ExecException: A problem occurred starting process 'Gradle build daemon'
#11 4.410       at org.gradle.process.internal.DefaultExecHandle.execExceptionFor(DefaultExecHandle.java:241)
#11 4.410       at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:218)
#11 4.410       at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:369)
#11 4.411       at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:87)
#11 4.411       at org.gradle.internal.operations.CurrentBuildOperationPreservingRunnable.run(CurrentBuildOperationPreservingRunnable.java:38)
#11 4.411       at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
#11 4.411       at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
#11 4.412       at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
#11 4.412       at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
#11 4.412       at java.base/java.lang.Thread.run(Thread.java:833)
#11 4.413 Caused by: net.rubygrapefruit.platform.NativeException: Could not start '/opt/java/openjdk/bin/java'
#11 4.413       at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
#11 4.413       at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
#11 4.415       at org.gradle.process.internal.ExecHandleRunner.startProcess(ExecHandleRunner.java:98)
#11 4.416       at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:71)
#11 4.416       ... 6 more
#11 4.416 Caused by: java.io.IOException: Cannot run program "/opt/java/openjdk/bin/java" (in directory "/home/gradle/.gradle/daemon/7.4.2"): error=0, Failed to exec spawn helper: pid: 67, exit value: 1
#11 4.417       at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
#11 4.417       at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
#11 4.417       at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
#11 4.417       ... 9 more
#11 4.418 Caused by: java.io.IOException: error=0, Failed to exec spawn helper: pid: 67, exit value: 1
#11 4.418       at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
#11 4.418       at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
#11 4.418       at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
#11 4.418       at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
#11 4.419       ... 11 more
#11 4.419 
#11 4.419 
#11 4.420 * Get more help at https://help.gradle.org
------
executor failed running [/bin/sh -c gradle shadowJar --stacktrace]: exit code: 1
ERROR: Service 'slack_bot' failed to build : Build failed


I don't know what else to try and the error details are not clear. Am I using the correct images?

Dockerfile:

FROM gradle:7.4.2-jdk17 as build
WORKDIR /usr/src/app
COPY . .
RUN gradle shadowJar

FROM adoptopenjdk:latest
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/build/libs ./

docker-compose.yml:

version: "3.8"
services:
  slack_bot:
    container_name: slack_bot
    platform: linux/amd64
    build: .
    ports:
      - "8000:8000"
    environment:
      PORT: 8000
    command: java -jar build/libs/slack-bot-1.0-SNAPSHOT-all.jar

Using JDK11:

FROM gradle:7.4.2-jdk11 as build
WORKDIR /usr/src/app
COPY . .
RUN gradle shadowJar --info

FROM adoptopenjdk:latest
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/build/libs ./

I get:

#11 27.96 Generating /home/gradle/.gradle/caches/7.4.2/generated-gradle-jars/gradle-api-7.4.2.jar
#11 27.96 ----- End of the daemon log -----
#11 27.96 
#11 27.96 JVM crash log found: file:///usr/src/app/hs_err_pid64.log
#11 28.00 
#11 28.00 FAILURE: Build failed with an exception.
#11 28.00 
#11 28.00 * What went wrong:
#11 28.00 Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
#11 28.00 
#11 28.00 * Try:
#11 28.00 > Run with --debug option to get more log output.
#11 28.01 > Run with --scan to get full insights.
#11 28.01 
#11 28.01 * Exception is:
#11 28.01 org.gradle.launcher.daemon.client.DaemonDisappearedException: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
#11 28.01       at org.gradle.launcher.daemon.client.DaemonClient.handleDaemonDisappearance(DaemonClient.java:269)
#11 28.01       at org.gradle.launcher.daemon.client.DaemonClient.monitorBuild(DaemonClient.java:242)
#11 28.01       at org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:204)
#11 28.01       at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:167)
#11 28.01       at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:99)
#11 28.01       at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:57)
#11 28.01       at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:210)
#11 28.01       at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:275)
#11 28.01       at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:247)
#11 28.01       at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:82)
#11 28.01       at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:30)
#11 28.01       at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:92)
#11 28.01       at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:38)
#11 28.01       at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:44)
#11 28.01       at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:26)
#11 28.01       at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:41)
#11 28.01       at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:26)
#11 28.01       at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:240)
#11 28.01       at org.gradle.launcher.Main.doAction(Main.java:35)
#11 28.01       at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
#11 28.01       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
#11 28.01       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
#11 28.01       at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
#11 28.01       at java.base/java.lang.reflect.Method.invoke(Method.java:566)
#11 28.01       at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
#11 28.01       at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
#11 28.01       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
#11 28.01       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
#11 28.01       at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
#11 28.01       at java.base/java.lang.reflect.Method.invoke(Method.java:566)
#11 28.01       at org.gradle.launcher.GradleMain.main(GradleMain.java:34)
#11 28.01 
#11 28.01 
#11 28.01 * Get more help at https://help.gradle.org
------
executor failed running [/bin/sh -c gradle shadowJar --info --stacktrace]: exit code: 1
ERROR: Service 'slack_bot' failed to build : Build failed

CodePudding user response:

It doesn't fail to build - it already fails the start the Gradle daemon ...
This is the jspawnhelper at fault; it possibly might lack x permission:

RUN chmod  x $JAVA_HOME/lib/jspawnhelper
RUN gradle :shadowJar
  • Or disable the Gradle daemon altogether; with one-shot builds it doesn't make a difference.

  • Or try -Djdk.lang.Process.launchMechanism=vfork?

CodePudding user response:

Gradle 7.4.2 is broken. You should downgrade to 7.4.1

  • Related