skip to Main Content

I have Jenkins 2.164.3 on a CentOS 7 server.
I have a Windows Server 2003 slave with Java version 1.8.0.
I have 3 x linux slaves working successfully.
The windows service on the slave is installed and running.
The windows slave is setup with the following with Launch Method “Let jenkins control this Windows salve as a Windows server”

This Jenkins server is a new server that replaced an older jenkins server (debian wheezy from turnkey linux ~3 years ago). This windows slave used to connect to that old server. To remove the connection on this slave to the old server, I did the following:
1. sc delete
2. deleted the files in folder c:jenkins
3. rebooted server
4. from new jenkins server, launched slave which copied files to c:jenkins folder and installed service.

On my new jenkins server, I setup the windows slave and when I connect, the log has the following:

[2019-05-27 12:24:07] [windows-slaves] Connecting to 192.168.1.152
Checking if Java exists
java -version returned 1.8.0.
[2019-05-27 12:24:16] [windows-slaves] Copying jenkins-slave.xml
[2019-05-27 12:24:16] [windows-slaves] Copying slave.jar
[2019-05-27 12:24:16] [windows-slaves] Starting the service
[2019-05-27 12:24:16] [windows-slaves] Waiting for the service to become ready
ERROR: [2019-05-27 12:24:52] [windows-slaves] The service did not respond. Perhaps it failed to launch?
[2019-05-27 12:36:00] [windows-slaves] Connecting to 192.168.1.152
Checking if Java exists
java -version returned 1.8.0.
[2019-05-27 12:36:08] [windows-slaves] Copying jenkins-slave.xml
[2019-05-27 12:36:08] [windows-slaves] Copying slave.jar
[2019-05-27 12:36:08] [windows-slaves] Starting the service
ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
org.jinterop.dcom.common.JIException: Service Already Running
    at org.jvnet.hudson.wmi.Win32Service$Implementation.start(Win32Service.java:149)
Caused: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.kohsuke.jinterop.JInteropInvocationHandler.invoke(JInteropInvocationHandler.java:140)
Caused: java.lang.reflect.UndeclaredThrowableException
    at com.sun.proxy.$Proxy90.start(Unknown Source)
    at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:342)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:294)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

The windows slave is Windows Server 2003, the service is installed and running.

In the log file C:Jenkinsjenkins-slave.wrapper.log, it has the following:

2019-05-27 12:19:32,644 INFO  - Starting ServiceWrapper in the service mode
2019-05-27 12:19:32,659 INFO  - Starting javaw.exe -Xrs  -jar "C:Jenkinsslave.jar" -tcp "C:Jenkinsport.txt"
2019-05-27 12:19:32,675 INFO  - Extension loaded: killOnStartup
2019-05-27 12:19:32,675 DEBUG - Checking the potentially runaway process with PID=1408
2019-05-27 12:19:32,675 DEBUG - No runaway process with PID=1408. The process has been already stopped.
2019-05-27 12:19:32,675 INFO  - Starting javaw.exe -Xrs  -jar "C:Jenkinsslave.jar" -tcp "C:Jenkinsport.txt"
2019-05-27 12:19:32,691 INFO  - Started process 4084
2019-05-27 12:19:32,691 DEBUG - Forwarding logs of the process System.Diagnostics.Process (javaw) to winsw.SizeBasedRollingLogAppender
2019-05-27 12:19:32,691 INFO  - Recording PID of the started process:4084. PID file destination is C:Jenkinsjenkins_agent.pid
2019-05-27 12:23:56,529 INFO  - Stopping jenkinsslave-C__Jenkins
2019-05-27 12:23:56,529 DEBUG - ProcessKill 4084
2019-05-27 12:23:56,561 INFO  - Stopping process 4084
2019-05-27 12:23:56,561 INFO  - Send SIGINT 4084
2019-05-27 12:23:56,561 WARN  - SIGINT to 4084 failed - Killing as fallback
2019-05-27 12:23:56,561 INFO  - Finished jenkinsslave-C__Jenkins
2019-05-27 12:23:56,561 DEBUG - Completed. Exit code is 0
2019-05-27 12:24:16,374 INFO  - Starting ServiceWrapper in the service mode
2019-05-27 12:24:16,390 INFO  - Starting javaw.exe -Xrs  -jar "C:Jenkinsslave.jar" -tcp "C:Jenkinsport.txt"
2019-05-27 12:24:16,405 INFO  - Extension loaded: killOnStartup
2019-05-27 12:24:16,405 DEBUG - Checking the potentially runaway process with PID=4084
2019-05-27 12:24:16,405 DEBUG - No runaway process with PID=4084. The process has been already stopped.
2019-05-27 12:24:16,405 INFO  - Starting javaw.exe -Xrs  -jar "C:Jenkinsslave.jar" -tcp "C:Jenkinsport.txt"
2019-05-27 12:24:16,421 INFO  - Started process 364
2019-05-27 12:24:16,421 DEBUG - Forwarding logs of the process System.Diagnostics.Process (javaw) to winsw.SizeBasedRollingLogAppender
2019-05-27 12:24:16,421 INFO  - Recording PID of the started process:364. PID file destination is C:Jenkinsjenkins_agent.pid

The error on the jenkins server shows the service is not running. On the windows slave machine, the service is running. What is the problem and how do I fix?

Thanks.

3

Answers


  1. I know this question is old and you’ve long moved on but maybe this will help someone. I ran into a similar problem with a Windows slave, specifically I was seeing it go through a cycle of restarts much like you were:

    2019-05-27 12:24:16,405 DEBUG - Checking the potentially runaway process with PID=4084
    2019-05-27 12:24:16,405 DEBUG - No runaway process with PID=4084. The process has been already stopped.
    2019-05-27 12:24:16,405 INFO  - Starting javaw.exe -Xrs  -jar "C:Jenkinsslave.jar" -tcp "C:Jenkinsport.txt"
    2019-05-27 12:24:16,421 INFO  - Started process 364
    

    To solve the problem I checked the following:

    • See if the Windows service is running, cycle it
    • In addition to checking the C:<path to jenkins>jenkins-slave.wrapper.log also have a look at C:<path to jenkins>jenkins-slave.err.log
      • The err log is where I found my problem, I had an issue with a cert unable to find valid certificate
    • Edit the C:<path to jenkins>jenkins-slave.xml file and fix whatever startup parameter is causing you a problem. Make sure to check the java path and version.
      • In my certificate error case, I needed to add a -noCertificateCheck to my arguments so I could move on
    Login or Signup to reply.
  2. Very old question, but if you end up here because you are getting this error, find the jenkins_agent.pid file and delete it. It should be in the same folder the rest of your jenkins slave files. The service should start again normally after that.

    Login or Signup to reply.
  3. Another potential downfall maybe that the executable setting in the jenkins-slave.xml config file no longer points to a valid java.exe.

    This may happen after a Java update

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search