【Jenkins】使用java -jar jenkins.war --httpPort=XXXX启动Jenkins报错【解决方案】

简介: 【Jenkins】使用java -jar jenkins.war --httpPort=XXXX启动Jenkins报错【解决方案】

使用java -jar jenkins.war --httpPort=XXXX启动Jenkins报错【解决方案】

👉欢迎关注博主【米码收割机】

👉一起学习C++、Python主流编程语言。

👉机器人、人工智能等相关领域开发技术。

👉主流开发、测试技能。



一. 启动Jenkins报错

错误1:错误描述

在cmd中,执行启动命令行:

java -jar jenkins.war --httpPort=8080

报错信息如下:

Main verifyJavaVersion

严重: Running with Java class version 63 which is not in the list of supported versions: [52, 55, 61]. Run with the --enable-future-java flag to enable such behavior. See https://jenkins.io/redirect/java-support/

java.lang.UnsupportedClassVersionError: 63.0

at Main.verifyJavaVersion(Main.java:147)

at Main.main(Main.java:108)

Jenkins requires Java versions [17, 8, 11] but you are running with Java 19 from D:\JDK-19

java.lang.UnsupportedClassVersionError: 63.0

at Main.verifyJavaVersion(Main.java:147)

at Main.main(Main.java:108)

错误1: 解决方案

根据提供的错误信息,您正在使用 Java 19,而 Jenkins 支持的 Java 版本为 8、11 和 17。为了解决此问题,您需要安装一个受支持的 Java 版本并将其设置为默认的 Java 版本。

1)安装JDK

下载并安装适合您操作系统的支持的 Java 版本(例如 JDK 8、11 或 17)。您可以从 Oracle 官方网站AdoptOpenJDK下载。

2)查看java版本

下载完成后,打开一个新的命令提示符窗口,运行以下命令以验证 Java 版本:

java -version

确保显示的版本与您安装的 JDK 版本相匹配。

3)重新启动 Jenkins

使用以下命令启动 Jenkins

java -jar jenkins.war --httpPort=8080

错误2:错误描述

在cmd中,执行启动命令行:

java -jar jenkins.war --httpPort=8080

报错信息如下:

Running from: D:\Jenkins\Jenkins.war

webroot: $user.home/.jenkins

2023-05-06 09:08:57.518+0000 [id=1] INFO org.eclipse.jetty.util.log.Log#initialized: Logging initialized @301ms to org.eclipse.jetty.util.log.JavaUtilLog

2023-05-06 09:08:57.572+0000 [id=1] INFO winstone.Logger#logInternal: Beginning extraction from war file

2023-05-06 09:08:57.586+0000 [id=1] WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath

2023-05-06 09:08:57.644+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: jetty-9.4.45.v20220203; built: 2022-02-03T09:14:34.105Z; git: 4a0c91c0be53805e3fcffdcdcc9587d5301863db; jvm 17.0.7+7

2023-05-06 09:08:57.925+0000 [id=1] INFO o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet

2023-05-06 09:08:57.955+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0

2023-05-06 09:08:57.956+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults

2023-05-06 09:08:57.957+0000 [id=1] INFO o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 660000ms

2023-05-06 09:08:58.287+0000 [id=1] INFO hudson.WebAppMain#contextInitialized: Jenkins home directory: C:\Users\mech-mind_lcl.jenkins found at: $user.home/.jenkins

2023-05-06 09:08:58.365+0000 [id=1] INFO o.e.j.s.handler.ContextHandler#doStart: Started w.@32057e6{Jenkins v2.346.2,/,file:///C:/Users/mech-mind_lcl/.jenkins/war/,AVAILABLE}{C:\Users\mech-mind_lcl.jenkins\war}

2023-05-06 09:08:58.374+0000 [id=1] INFO o.e.j.server.AbstractConnector#doStop: Stopped ServerConnector@282003e1{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}

2023-05-06 09:08:58.375+0000 [id=1] INFO o.e.j.server.session.HouseKeeper#stopScavenging: node0 Stopped scavenging

2023-05-06 09:08:58.378+0000 [id=1] INFO hudson.WebAppMain#contextDestroyed: Shutting down a Jenkins instance that was still starting up

java.lang.Throwable: reason

at hudson.WebAppMain.contextDestroyed(WebAppMain.java:383)

at org.eclipse.jetty.server.handler.ContextHandler.callContextDestroyed(ContextHandler.java:1080)

at org.eclipse.jetty.servlet.ServletContextHandler.callContextDestroyed(ServletContextHandler.java:584)

at org.eclipse.jetty.server.handler.ContextHandler.contextDestroyed(ContextHandler.java:1043)

at org.eclipse.jetty.servlet.ServletHandler.doStop(ServletHandler.java:319)

at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:94)

at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:180)

at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:201)

at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:108)

at org.eclipse.jetty.security.SecurityHandler.doStop(SecurityHandler.java:430)

at org.eclipse.jetty.security.ConstraintSecurityHandler.doStop(ConstraintSecurityHandler.java:423)

at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:94)

at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:180)

at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:201)

at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:108)

at org.eclipse.jetty.server.session.SessionHandler.doStop(SessionHandler.java:520)

at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:94)

at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:180)

at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:201)

at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:108)

at org.eclipse.jetty.server.handler.ContextHandler.stopContext(ContextHandler.java:1066)

at org.eclipse.jetty.servlet.ServletContextHandler.stopContext(ServletContextHandler.java:386)

at org.eclipse.jetty.webapp.WebAppContext.stopWebapp(WebAppContext.java:1454)

at org.eclipse.jetty.webapp.WebAppContext.stopContext(WebAppContext.java:1420)

at org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:1120)

at org.eclipse.jetty.servlet.ServletContextHandler.doStop(ServletContextHandler.java:297)

at org.eclipse.jetty.webapp.WebAppContext.doStop(WebAppContext.java:547)

at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:94)

at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:180)

at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:201)

at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:108)

at org.eclipse.jetty.server.Server.doStop(Server.java:470)

at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:94)

at winstone.Launcher.shutdown(Launcher.java:354)

at winstone.Launcher.(Launcher.java:217)

at winstone.Launcher.main(Launcher.java:405)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:568)

at Main._main(Main.java:342)

at Main.main(Main.java:117)

2023-05-06 09:08:58.383+0000 [id=1] INFO o.e.j.s.handler.ContextHandler#doStop: Stopped w.@32057e6{Jenkins v2.346.2,/,null,STOPPED}{C:\Users\mech-mind_lcl.jenkins\war}

Exception in thread “Jenkins initialization thread” java.lang.NoClassDefFoundError: hudson/util/HudsonFailedToLoad

at hudson.WebAppMain$3.run(WebAppMain.java:261)

Caused by: java.lang.ClassNotFoundException: hudson.util.HudsonFailedToLoad

at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)

at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)

at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)

at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:538)

at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)

… 1 more

2023-05-06 09:08:58.386+0000 [id=1] INFO winstone.Logger#logInternal: Jetty shutdown successfully

java.io.IOException: Failed to start Jetty

at winstone.Launcher.(Launcher.java:206)

at winstone.Launcher.main(Launcher.java:405)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:568)

at Main._main(Main.java:342)

at Main.main(Main.java:117)

Caused by: java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:8080

at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:349)

at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:310)

at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)

at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:234)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)

at org.eclipse.jetty.server.Server.doStart(Server.java:401)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)

at winstone.Launcher.(Launcher.java:202)

… 7 more

Caused by: java.net.BindException: Address already in use: bind

at java.base/sun.nio.ch.Net.bind0(Native Method)

at java.base/sun.nio.ch.Net.bind(Net.java:555)

at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337)

at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294)

at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:89)

at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344)

… 14 more

2023-05-06 09:08:58.391+0000 [id=1] SEVERE winstone.Logger#logInternal: Container startup failed

java.net.BindException: Address already in use: bind

at java.base/sun.nio.ch.Net.bind0(Native Method)

at java.base/sun.nio.ch.Net.bind(Net.java:555)

at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337)

at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294)

at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:89)

at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344)

Caused: java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:8080

at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:349)

at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:310)

at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)

at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:234)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)

at org.eclipse.jetty.server.Server.doStart(Server.java:401)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)

at winstone.Launcher.(Launcher.java:202)

Caused: java.io.IOException: Failed to start Jetty

at winstone.Launcher.(Launcher.java:206)

at winstone.Launcher.main(Launcher.java:405)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:568)

at Main._main(Main.java:342)

at Main.main(Main.java:117)

错误2: 解决方案(方法1)

从日志中可以看出,Jenkins启动失败的原因是端口冲突。错误信息显示:“Address already in use: bind”,表明8080端口已被其他程序占用。因此,Jenkins无法在8080端口上启动。


1)切换端口启动

在cmd中,使用8081或其他端口启动:

java -jar jenkins.war --httpPort=8082

2)浏览器查看

打开浏览器输入http://localhost:8082。可以看到Jenkins已经启动。

1ea22b2c87c842dda5dc9acd18043b1c.png

错误2: 解决方案(方法2)

1)关闭被占用的端口

查找并关闭占用8080端口的程序:使用以下命令查找占用8080端口的程序:

Windows:

netstat -ano | findstr :8080

Linux:

sudo lsof -i :8080

找到占用端口的程序后,结束相关进程,然后重新启动Jenkins。

2)浏览器查看

打开浏览器输入http://localhost:8080。可以看到Jenkins已经启动。

相关文章
|
27天前
|
JSON Java 关系型数据库
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
在Java中,使用mybatis-plus更新实体类对象到mysql,其中一个字段对应数据库中json数据类型,更新时报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
41 4
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
|
1月前
|
分布式计算 Java MaxCompute
ODPS MR节点跑graph连通分量计算代码报错java heap space如何解决
任务启动命令:jar -resources odps-graph-connect-family-2.0-SNAPSHOT.jar -classpath ./odps-graph-connect-family-2.0-SNAPSHOT.jar ConnectFamily 若是设置参数该如何设置
|
1月前
|
数据采集 分布式计算 Java
Kettle的Java开发环境需要什么jar包?
【10月更文挑战第24天】Kettle的Java开发环境需要什么jar包?
103 2
|
1月前
|
安全 小程序 Java
Java“AccessControlException”报错解决
Java中的“AccessControlException”通常发生在尝试访问受安全策略限制的资源时。解决方法包括:1. 检查安全策略文件(java.policy)配置;2. 确保代码具有足够的权限;3. 调整JVM启动参数以放宽安全限制。
134 1
|
3月前
|
消息中间件 分布式计算 Java
Linux环境下 java程序提交spark任务到Yarn报错
Linux环境下 java程序提交spark任务到Yarn报错
49 5
|
3月前
|
域名解析 分布式计算 网络协议
java遍历hdfs路径信息,报错EOFException
java遍历hdfs路径信息,报错EOFException
41 3
|
3月前
|
缓存 Java Linux
java操作hbase报错:KeeperErrorCode=NoNode for /hbase-unsecure/master
java操作hbase报错:KeeperErrorCode=NoNode for /hbase-unsecure/master
207 2
|
3月前
|
Java
java服务调用报错503
java服务调用报错503
36 2
|
3月前
|
JSON Java 数据格式
java调用服务报错400
java调用服务报错400
73 2
|
2月前
|
Java
【Azure Developer】com.azure:azure-identity jar包版本从1.2.0 升级到1.12.2 版本之后报错
在将 `com.azure:azure-identity` 的 jar 包版本从 1.2.0 升级到 1.12.2 后出现错误,错误信息表明存在方法未找到的问题。分析显示这是由于依赖管理错误导致,需要调整 classpath 确保使用兼容版本的依赖包。当前项目中 msal4j-1.11.0.jar 与 azure-identity-1.12.2 不兼容。
下一篇
DataWorks