27

I have Jenkins running on Windows as a service. Normally, it starts when machine starts.

After a Windows recommended update this afternoon, and a machine restart, my Jenkins just stopped working.

I start the service but it stops and shows the following warning:

"The Jenkins service on Local Computer started and then stopped. Some 
services stop automatically if they are not in use by other services or 
programs."

There is no "jenkins.err.log" file and if I start Jenkins with "java jenkins.war" It works fine.

Any tip whats going on? How to fix this? Please help.

Thank you very much.

stefanobaghino
  • 11,253
  • 4
  • 35
  • 63
koxta
  • 846
  • 2
  • 8
  • 30

11 Answers11

62

I had the same problem. It appeared that the java runtime enviromment had been updated. In the jenkins installation folder there is as jenkins.wrapper.log. This contains logging from the jenkins.exe service wrapper. In my case it tried to start java from c:\Program Files\Java\jre1.8.0_144\bin. This folder did not exist, instead, java was installed in c:\Program Files\Java\jre1.8.0_161\bin.

In the jenkins installation folder there is also a jenkins.xml. This contains the reference to the java installation in the tag. Change it to your current java installation and it will start again.

user1777224
  • 838
  • 7
  • 7
6

if your java path is correct, disable RunawayProcessKiller in jenkins.xml

extension enabled="**false**" className="winsw.Plugins.RunawayProcessKiller.RunawayProcessKillerExtension"
brooksrelyt
  • 3,925
  • 5
  • 31
  • 54
Scott V
  • 61
  • 1
  • 2
  • My issue was also a runaway path related to the jenkins.pid. Instead of disabling the process killer, you can find the offending hung process or reboot your server. – David Jan 29 '20 at 22:05
5

I also had this problem after each java update. But there is a version-independent absolute path, that can be used to start the java run-time: C:\ProgramData\Oracle\Java\javapath\java.exe.

I changed jenkins-slave.xml to use this path:

<executable>C:\ProgramData\Oracle\Java\javapath\java.exe</executable>
Mario Klebsch
  • 361
  • 2
  • 12
3

If the java.exe path is setup correctly in the jenkins.xml/jenkins-slave.xml file and the problem persists, then try to delete the jenkins_agent.pid file and restart the service.

SAzam
  • 31
  • 4
1

In my case this happened after I installed some updates on my machine. After some research (jenkins.err.log) it turned out that some other application grabbed the port 8080 that was used by Jenkins up to this point.

I managed to identify the app (with TcpView) and disabled it.

Problem solved.

uceumern
  • 877
  • 10
  • 14
1

In my case, I installed JDK 17.0.2, but Jenkins requires version JDK 8 to 11. Check error log under C:\Program Files\Jenkins\jenkins.err for exect error.

Palash Roy
  • 1,547
  • 1
  • 15
  • 11
0

My issue was installation of an (unwanted) service that also listens on port 8080. That service failed to start on installation because Jenkins was running at the time, but after a reboot the rogue service started more quickly and nabbed the port. The fix was to disable the unwanted service.

from jenkins.err.log:

java.net.BindException: Address already in use: bind
Caused: java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:8080
Robert Calhoun
  • 4,823
  • 1
  • 38
  • 34
0

Your first stop should be the Windows Event Viewer logs to get a better idea of the underlying error. In my case the error read:

Service cannot be started. System.ComponentModel.Win32Exception (0x80004005): Access is denied
   at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
   at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
   at System.Diagnostics.Process.OpenProcessHandle(Int32 access)
   at System.Diagnostics.Process.get_Handle()
   at winsw.Plugins.RunawayProcessKiller.RunawayProcessKillerExtension.OnWrapperStarted()
   at winsw.Extensions.WinSWExtensionManager.FireOnWrapperStarted()
   at winsw.WrapperService.OnStart(String[] args)
   at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

You can examine your Jenkins configuration by looking at jenkins.xml. In my case this included configuration for a RunawayProcessExtension which terminates previous instances of Jenkins before starting the new instance. The <pidfile> entry stores the location of a text file with the PID of the last known instance of Jenkins.

In my case, this <pidfile> was pointing to a PID that was no longer used by a running Jenkins process. Instead, that slot had been taken over by a system process (csrss.exe), causing the RunawayProcessExtension to throw an exception with an "access denied" message when trying to terminate it. Jenkins itself was not starting because it was expecting the RunawayProcessExtension to terminate first.

The solution was to delete the <pidfile> and then restart the service.

Philip Atz
  • 886
  • 1
  • 10
  • 26
0

It is happing as Jenkins is not able to find java(jdk) path. check jdk path in jenkins.xml file

Resolved this issues java -version
where java
check jdk/bin -- copy this jdk path Goto jenkin.xml file and change java path

Vishal Kaneria
  • 11
  • 1
  • 1
  • 5
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 05 '23 at 20:53
-3

To resolve this problem follow bellow steps -

  1. Open window task manager(use CTRL + ALT + Delete button)
  2. Navigate to service on the task manager
  3. Click 'Services..' button on task manager
  4. Services window gets opened > Search the Jenkins service and re-start/Start the Jenkins service Refer Image - Jenkins Service
  5. Now try accessing the Jenkins, problem re-solved
  • Hello Ajit, sorry but this wont work. The question says "I start the service but it stops" so restart/start wont work because the service was starting with the wrong java version. Already solved. Thanks for the contribution. – koxta Nov 30 '18 at 15:21
-5

Jenkins service might be stoped.Find the jenkins service in window services and click start.I tried it many times.It worked

Ajay K
  • 1