Jenkins启动失败之解决
前提

前往Jenkins官方网站https://jenkins.io/下载最新的war包
正题

在终端输入:java -jar jenkins.war
报错:

MacBook-Pro:downloads GaoSir javajarjenkins.warRunningfrom:/Users/apple/Downloads/jenkins.warwebroot: j a v a − j a r j e n k i n s . w a r R u n n i n g f r o m : / U s e r s / a p p l e / D o w n l o a d s / j e n k i n s . w a r w e b r o o t : user.home/.jenkins
十一月 06, 2017 5:40:04 下午 Main deleteWinstoneTempContents
警告: Failed to delete the temporary Winstone file /var/folders/kn/bn1v95dj0wl7cmyn0p057y_r0000gn/T/winstone/jenkins.war
十一月 06, 2017 5:40:04 下午 org.eclipse.jetty.util.log.Log initialized
信息: Logging initialized @370ms to org.eclipse.jetty.util.log.JavaUtilLog
十一月 06, 2017 5:40:04 下午 winstone.Logger logInternal
信息: Beginning extraction from war file
十一月 06, 2017 5:40:04 下午 org.eclipse.jetty.server.handler.ContextHandler setContextPath
警告: Empty contextPath
十一月 06, 2017 5:40:04 下午 org.eclipse.jetty.server.Server doStart
信息: jetty-9.4.z-SNAPSHOT
十一月 06, 2017 5:40:04 下午 org.eclipse.jetty.webapp.StandardDescriptorProcessor visitServlet
信息: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
十一月 06, 2017 5:40:05 下午 org.eclipse.jetty.server.session.DefaultSessionIdManager doStart
信息: DefaultSessionIdManager workerName=node0
十一月 06, 2017 5:40:05 下午 org.eclipse.jetty.server.session.DefaultSessionIdManager doStart
信息: No SessionScavenger set, using defaults
十一月 06, 2017 5:40:05 下午 org.eclipse.jetty.server.session.HouseKeeper startScavenging
信息: Scavenging every 660000ms
Jenkins home directory: /Users/apple/.jenkins found at: $user.home/.jenkins
十一月 06, 2017 5:40:06 下午 org.eclipse.jetty.server.handler.ContextHandler doStart
信息: Started w.@305ffe9e{/,file:///Users/apple/.jenkins/war/,AVAILABLE}{/Users/apple/.jenkins/war}
十一月 06, 2017 5:40:06 下午 org.eclipse.jetty.server.AbstractConnector doStop
信息: Stopped ServerConnector@5a59ca5e{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
十一月 06, 2017 5:40:06 下午 org.eclipse.jetty.server.session.HouseKeeper stopScavenging
信息: Stopped scavenging
十一月 06, 2017 5:40:06 下午 hudson.WebAppMain contextDestroyed
信息: Shutting down a Jenkins instance that was still starting up
java.lang.Throwable: reason
at hudson.WebAppMain.contextDestroyed(WebAppMain.java:388)
at org.eclipse.jetty.server.handler.ContextHandler.callContextDestroyed(ContextHandler.java:898)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextDestroyed(ServletContextHandler.java:545)
at org.eclipse.jetty.server.handler.ContextHandler.stopContext(ContextHandler.java:873)
at org.eclipse.jetty.servlet.ServletContextHandler.stopContext(ServletContextHandler.java:355)
at org.eclipse.jetty.webapp.WebAppContext.stopWebapp(WebAppContext.java:1507)
at org.eclipse.jetty.webapp.WebAppContext.stopContext(WebAppContext.java:1471)
at org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:927)
at org.eclipse.jetty.servlet.ServletContextHandler.doStop(ServletContextHandler.java:271)
at org.eclipse.jetty.webapp.WebAppContext.doStop(WebAppContext.java:569)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:142)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:160)
at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:124)
at org.eclipse.jetty.server.Server.doStop(Server.java:523)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
at winstone.Launcher.shutdown(Launcher.java:307)
at winstone.Launcher.(Launcher.java:167)
at winstone.Launcher.main(Launcher.java:354)
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:483)
at Main._main(Main.java:294)
at Main.main(Main.java:132)

十一月 06, 2017 5:40:06 下午 org.eclipse.jetty.server.handler.ContextHandler doStop
信息: Stopped w.@305ffe9e{/,null,UNAVAILABLE}{/Users/apple/.jenkins/war}
十一月 06, 2017 5:40:06 下午 winstone.Logger logInternal
信息: Winstone shutdown successfully
java.io.IOException: Failed to start Jetty
at winstone.Launcher.(Launcher.java:156)
at winstone.Launcher.main(Launcher.java:354)
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:483)
at Main._main(Main.java:294)
at Main.main(Main.java:132)
Caused by: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:414)
at sun.nio.ch.Net.bind(Net.java:406)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:298)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:431)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at winstone.Launcher.(Launcher.java:154)
… 7 more
Exception in thread “Jenkins initialization thread” java.lang.NoClassDefFoundError: hudson/util/HudsonFailedToLoad
at hudson.WebAppMain 3.run(WebAppMain.java:247)Causedby:java.lang.ClassNotFoundException:hudson.util.HudsonFailedToLoadatjava.net.URLClassLoader 3. r u n ( W e b A p p M a i n . j a v a : 247 ) C a u s e d b y : j a v a . l a n g . C l a s s N o t F o u n d E x c e p t i o n : h u d s o n . u t i l . H u d s o n F a i l e d T o L o a d a t j a v a . n e t . U R L C l a s s L o a d e r 1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:560)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
… 1 more
十一月 06, 2017 5:40:06 下午 winstone.Logger logInternal
严重: Container startup failed
java.io.IOException: Failed to start Jetty
at winstone.Launcher.(Launcher.java:156)
at winstone.Launcher.main(Launcher.java:354)
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:483)
at Main._main(Main.java:294)
at Main.main(Main.java:132)
Caused by: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:414)
at sun.nio.ch.Net.bind(Net.java:406)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:298)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:431)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at winstone.Launcher.(Launcher.java:154)
… 7 more

How to deal with it?

Jenkins默认端口号是8080,而8080被占用了,so…
只要把端口号改了就行了:java -jar jenkins.war –httpPort=$HTTP_PORT。

例如:java -jar jenkins.war –httpPort=1080

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐