执行war文件

时间:2017-10-27 18:50:53

标签: jenkins

我在Windows中使用Jenkins 2.73.1。执行以下命令安装Jenkins时,

java -jar jenkins.war

我收到以下错误:

C:\Program Files (x86)\Jenkins>java -jar jenkins.war
Running from: C:\Program Files (x86)\Jenkins\jenkins.war
webroot: $user.home/.jenkins
[33mOct 28, 2017 12:01:28 AM Main deleteWinstoneTempContents
WARNING: Failed to delete the temporary Winstone file C:\Users\user\AppData\Local\Temp\winstone\jenkins.war
[0mOct 28, 2017 12:01:28 AM org.eclipse.jetty.util.log.Log initialized
INFO: Logging initialized @1490ms to org.eclipse.jetty.util.log.JavaUtilLog
Oct 28, 2017 12:01:28 AM winstone.Logger logInternal
INFO: Beginning extraction from war file
[33mOct 28, 2017 12:01:28 AM org.eclipse.jetty.server.handler.ContextHandler setContextPath
WARNING: Empty contextPath
[0mOct 28, 2017 12:01:28 AM org.eclipse.jetty.server.Server doStart
INFO: jetty-9.4.z-SNAPSHOT
Oct 28, 2017 12:01:31 AM org.eclipse.jetty.webapp.StandardDescriptorProcessor visitServlet
INFO: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
Oct 28, 2017 12:01:31 AM org.eclipse.jetty.server.session.DefaultSessionIdManager doStart
INFO: DefaultSessionIdManager workerName=node0
Oct 28, 2017 12:01:31 AM org.eclipse.jetty.server.session.DefaultSessionIdManager doStart
INFO: No SessionScavenger set, using defaults
Oct 28, 2017 12:01:31 AM org.eclipse.jetty.server.session.HouseKeeper startScavenging
INFO: Scavenging every 660000ms
Jenkins home directory: C:\Users\user\.jenkins found at: $user.home/.jenkins
Oct 28, 2017 12:01:33 AM org.eclipse.jetty.server.handler.ContextHandler doStart
INFO: Started w.@4bdeaabb{/,file:///C:/Users/user/.jenkins/war/,AVAILABLE}{C:\Users\user\.jenkins\war}
Oct 28, 2017 12:01:33 AM org.eclipse.jetty.server.AbstractConnector doStop
INFO: Stopped ServerConnector@7a5ceedd{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
Oct 28, 2017 12:01:33 AM org.eclipse.jetty.server.session.HouseKeeper stopScavenging
INFO: Stopped scavenging
Oct 28, 2017 12:01:33 AM hudson.WebAppMain contextDestroyed
INFO: Shutting down a Jenkins instance that was still starting up
java.lang.Throwable: reason
        at hudson.WebAppMain.contextDestroyed(WebAppMain.java:390)
        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.<init>(Launcher.java:167)
        at winstone.Launcher.main(Launcher.java:354)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at Main._main(Main.java:294)
        at Main.main(Main.java:132)

Oct 28, 2017 12:01:33 AM org.eclipse.jetty.server.handler.ContextHandler doStop
INFO: Stopped w.@4bdeaabb{/,null,UNAVAILABLE}{C:\Users\user\.jenkins\war}
Exception in thread "Jenkins initialization thread" java.lang.NoClassDefFoundError: hudson/util/HudsonFailedToLoad
        at hudson.WebAppMain$3.run(WebAppMain.java:249)
Caused by: java.lang.ClassNotFoundException: hudson.util.HudsonFailedToLoad
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:560)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more
Oct 28, 2017 12:01:33 AM winstone.Logger logInternal
INFO: Winstone shutdown successfully
java.io.IOException: Failed to start Jetty
        at winstone.Launcher.<init>(Launcher.java:156)
        at winstone.Launcher.main(Launcher.java:354)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at Main._main(Main.java:294)
        at Main.main(Main.java:132)
Caused by: java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        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.<init>(Launcher.java:154)
        ... 7 more
[31mOct 28, 2017 12:01:33 AM winstone.Logger logInternal
SEVERE: Container startup failed
java.io.IOException: Failed to start Jetty
        at winstone.Launcher.<init>(Launcher.java:156)
        at winstone.Launcher.main(Launcher.java:354)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at Main._main(Main.java:294)
        at Main.main(Main.java:132)
Caused by: java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        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.<init>(Launcher.java:154)
        ... 7 more

[0m

有人可以帮忙吗?

5 个答案:

答案 0 :(得分:10)

根据我的分析,Jenkins默认会尝试使用端口号为8080.您遇到此问题,因为端口号(8080)已经被其他一些进程占用,如tomcat或oracle或其他。< / p>

当我在运行jenkins.war时传递了自己的端口号时,这个问题就解决了。它成功运行并下载了所有元数据。您可以看到以下命令如何通过端口,

HTTP

java -jar jenkins.war --httpPort=9090

HTTPS

java -jar jenkins.war --httpsPort=9090

注意:最初我甚至遇到过ClassNotFountException。当我尝试使用新的端口号时,我没有任何异常。

答案 1 :(得分:4)

好吧,我在堆栈跟踪中看到的一些东西似乎很可能会导致问题。特别是这两个:

Exception in thread "Jenkins initialization thread" java.lang.NoClassDefFoundError: hudson/util/HudsonFailedToLoad
Caused by: java.lang.ClassNotFoundException: hudson.util.HudsonFailedToLoad

java.io.IOException: Failed to start Jetty
Caused by: java.net.BindException: Address already in use: bind

基本上,这里有两个问题,第一个是你的Jenkins尝试绑定的端口已经在使用,试着找出使用端口jetty想要绑定的端口(通常是80或8080,如果我的记忆服务)。

第二个是一个问题,我认为找不到它试图抛出的异常的类。

我不确定这是怎么发生的,我会释放端口,看看问题是否消失,如果没有弄清楚为什么你的类路径中缺少这个类

答案 2 :(得分:2)

(已解决)

正确,当您尝试使用端口8080上的java -jar jenkins.war(默认情况下)启动jenkins时,会发生此错误。

  

线程“ Jenkins初始化线程”中的异常   java.lang.NoClassDefFoundError:hudson / util / HudsonFailedToLoad导致   创建人:java.lang.ClassNotFoundException:hudson.util.HudsonFailedToLoad

首先使用以下步骤检查端口8080>

步骤1: 以管理员身份运行命令行。然后运行以下提及 命令。

netstat -ano | findstr:yourPortNumber

TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       8016

TCP    [::]:8080              [::]:0                 LISTENING       8016

获取PID(进程标识符): 8016 (在您的系统中将有所不同)

然后在识别出PID(8016)之后执行此命令。

第2步:

taskkill /PID typeyourPIDhere /F
再次运行netstat -ano | findstr:yourPortNumber并检查端口是否关闭。

学习愉快:)

答案 3 :(得分:1)

if false then false else true then true中一样更新端口。

答案 4 :(得分:0)

我也面临类似的问题。步骤解决了我的问题如下:

  1. 检查Tomcat服务是否已启动并正在运行。如果没有,那么请先开始。
  2. 就我而言,STS使用默认的tomcat。我已经结束了这个过程。
  3. 执行命令&gt; java -jar jenkins.war -httpPort = 9090
  4. 它对我有用。