# Java error on jenkins while trying to add jenkins agent

**URL:** <https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953>\
**Category:** Ask a question\
**Created:** [December 20, 2024, 4:59am UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953 "2024-12-20T04:59:10Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![jatin765](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jatin765](https://community.jenkins.io/u/jatin765)\
**Post date:** [December 20, 2024, 4:59am UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/1 "2024-12-20T04:59:10Z")

</div>

```auto
java.io.IOException: error=0, Failed to exec spawn helper: pid: 1959574, exit value: 1
	at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
	at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
	at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
Caused: java.io.IOException: Cannot run program "ssh": error=0, Failed to exec spawn helper: pid: 1959574, exit value: 1
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
	at hudson.slaves.CommandLauncher.launch(CommandLauncher.java:163)
	at hudson.slaves.SlaveComputer.lambda$_connect$0(SlaveComputer.java:297)
	at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
	at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:80)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

```

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [December 20, 2024, 8:26am UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/2 "2024-12-20T08:26:33Z")

</div>

you need to provide more information if someone should help.  
How did you configure the agent? From the stacktrace it looks as if you used the [Command Agent Launcher](https://plugins.jenkins.io/command-launcher/) plugin to launch the agent but then you want to make an ssh call. For ssh you better use the [SSH Build Agents](https://plugins.jenkins.io/ssh-slaves/) plugin

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [December 20, 2024, 2:07pm UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/3 "2024-12-20T14:07:28Z")

</div>

> [@jatin765](#):
>
> `java.io.IOException: error=0, Failed to exec spawn helper`

I think that I remember a change in a Java upgrade that caused the Java spawn helper script to change name or otherwise become different between one Java update and the next. You might want to be sure that the agent has been stopped and restarted since the most recent Java patch was applied.

Refer to [Jenkins issue: FATAL: command execution failed - #8 by jspiewak](https://community.jenkins.io/t/jenkins-issue-fatal-command-execution-failed/12460/8) for more details.

---

<div class="post-metadata">

**Author:** ![jatin765](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jatin765](https://community.jenkins.io/u/jatin765)\
**Post date:** [December 23, 2024, 7:08am UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/4 "2024-12-23T07:08:19Z")

</div>

I configured it using command launch from the jenkins configuration. it will basically run the jar file to add agent in controller.

---

<div class="post-metadata">

**Author:** ![jatin765](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jatin765](https://community.jenkins.io/u/jatin765)\
**Post date:** [December 23, 2024, 7:14am UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/5 "2024-12-23T07:14:09Z")

</div>

I am currently using java 11.0.25

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [December 23, 2024, 7:25am UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/6 "2024-12-23T07:25:31Z")

</div>

Anyway if you still see this problem you will probably need to restart your controller if the assumption from Mark is correct

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [December 23, 2024, 9:33am UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/8 "2024-12-23T09:33:25Z")

</div>

Please provide more details.  
Which Jenkins version are you using?  
Which java version are you using to run the controller and which java version for the agent.  
How are you trying to run the agent? With CommandLauncher, then please let us know the command you’re trying to run

---

<div class="post-metadata">

**Author:** ![jatin765](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jatin765](https://community.jenkins.io/u/jatin765)\
**Post date:** [December 23, 2024, 6:52pm UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/9 "2024-12-23T18:52:02Z")

</div>

jenkins version: 2.440.3  
Java running on controller : 17.0.11  
controller OS: UBUNTU 20.04  
java running on agent: 17.0.13  
Agent OS: UBUNTU 22.04

launch command: ssh ‘agent ip’ java -jar ~/bin/agent.jar

---

<div class="post-metadata">

**Author:** ![jatin765](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jatin765](https://community.jenkins.io/u/jatin765)\
**Post date:** [December 24, 2024, 7:10am UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/10 "2024-12-24T07:10:05Z")

</div>

Also M using “-Djdk.lang.Process.launchMechanism=vfork” at the time of command launch but still not working!!

---

<div class="post-metadata">

**Author:** ![kuisathaverat](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/kuisathaverat/32/101_2.png) [@kuisathaverat](https://community.jenkins.io/u/kuisathaverat)\
**Post date:** [December 24, 2024, 8:55am UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/11 "2024-12-24T08:55:54Z")

</div>

You do not have (or it is not in the PATH) an SSH CLI in the Jenkins Controller, so when you try to launch the agent with the command `ssh IP java -jar ~/bin/agnet.jar`, the controller does not find `ssh`in the PATH of the user that runs the Jenkins process.

---

<div class="post-metadata">

**Author:** ![jatin765](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jatin765](https://community.jenkins.io/u/jatin765)\
**Post date:** [December 24, 2024, 4:48pm UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/12 "2024-12-24T16:48:14Z")

</div>

I have ssh in the controller with that user as well

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [December 24, 2024, 5:09pm UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/13 "2024-12-24T17:09:12Z")

</div>

> [@jatin765](#):
>
> jenkins version: 2.440.3  
> Java running on controller : 17.0.11  
> controller OS: UBUNTU 20.04

Java 17.0.11 is over 6 months out of date. I would be surprised if Ubuntu were not trying to update it to the current Java 17.0.13. If Java is upgraded on the controller while the controller is running, then there is a high risk of the “spawn helper” message appearing. If a previous Java upgrade was incomplete or damaged, that might also cause the “spawn helper” message.

Ubuntu 20.04 will be unsupported by the Jenkins project in April 2025. You have less than 6 months before that operating system is unsupported by Jenkins.

Jenkins 2.440.3 has known at least one known [critical security vulnerability](https://www.jenkins.io/security/advisory/2024-08-07/). Upgrade Jenkins as soon as you can.

---

<div class="post-metadata">

**Author:** ![kuisathaverat](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/kuisathaverat/32/101_2.png) [@kuisathaverat](https://community.jenkins.io/u/kuisathaverat)\
**Post date:** [December 24, 2024, 5:39pm UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/14 "2024-12-24T17:39:39Z")

</div>

Try to use the absolute path instead of only the command

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [December 24, 2024, 10:08pm UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/15 "2024-12-24T22:08:32Z")

</div>

Another point is that it is probably better to use the [SSH Build Agents](https://plugins.jenkins.io/ssh-slaves/) to connect agents with ssh than using the command launcher plugin. It avoids that an external ssh process is started at all.

---

<div class="post-metadata">

**Author:** ![jatin765](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jatin765](https://community.jenkins.io/u/jatin765)\
**Post date:** [December 30, 2024, 10:41am UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/16 "2024-12-30T10:41:00Z")

</div>

Can we do something with the agent to fix the issue. As controller is on production. I cannot do anything in that.

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [December 30, 2024, 12:37pm UTC](https://community.jenkins.io/t/java-error-on-jenkins-while-trying-to-add-jenkins-agent/24953/17 "2024-12-30T12:37:50Z")

</div>

> [@jatin765](#):
>
> Can we do something with the agent to fix the issue?

Not as far as I can tell. If I am reading the stack trace correctly, the stack trace indicates that the `Failed to exec spawn helper` is happening on the Jenkins controller. Changes on the agent won’t help.

If the failure is due to a Java upgrade that has happened while the Jenkins controller is running, then I think that means that you should be able to resolve the issue by restarting the Java process that runs the Jenkins controller.
