在 Linux EC2 实例上更新后,我在启动 jenkins 时遇到问题。之前安装了旧版本的 Java,我使用yum命令进行了更新
sudo systemctl status jenkins.service
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Fri 2024-06-28 20:07:46 BST; 2min 0s ago
Process: 4671 ExecStart=/usr/bin/jenkins (code=exited, status=1/FAILURE)
Main PID: 4671 (code=exited, status=1/FAILURE)
Jun 28 20:07:46 ip-172-31-28-49.eu-west-1.compute.internal systemd[1]: jenkins.service: main process exited, code=exited, status=1/FAILURE
Jun 28 20:07:46 ip-172-31-28-49.eu-west-1.compute.internal systemd[1]: Failed to start Jenkins Continuous Integration Server.
Jun 28 20:07:46 ip-172-31-28-49.eu-west-1.compute.internal systemd[1]: Unit jenkins.service entered failed state.
Jun 28 20:07:46 ip-172-31-28-49.eu-west-1.compute.internal systemd[1]: jenkins.service failed.
Jun 28 20:07:46 ip-172-31-28-49.eu-west-1.compute.internal systemd[1]: jenkins.service holdoff time over, scheduling restart.
Jun 28 20:07:46 ip-172-31-28-49.eu-west-1.compute.internal systemd[1]: start request repeated too quickly for jenkins.service
Jun 28 20:07:46 ip-172-31-28-49.eu-west-1.compute.internal systemd[1]: Failed to start Jenkins Continuous Integration Server.
Jun 28 20:07:46 ip-172-31-28-49.eu-west-1.compute.internal systemd[1]: Unit jenkins.service entered failed state.
Jun 28 20:07:46 ip-172-31-28-49.eu-west-1.compute.internal systemd[1]: jenkins.service failed.
Java 版本详细信息
java --version
openjdk 11.0.23 2024-04-16 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.23.0.9-2.amzn2.0.1) (build 11.0.23+9-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.23.0.9-2.amzn2.0.1) (build 11.0.23+9-LTS, mixed mode, sharing)
当我运行 jenkins 版本命令时出现以下错误
jenkins -version
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: executable/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
我认为这是一个 Java 问题,因此我尝试安装以下 Java 版本,即
有3个程序提供‘java’。
Selection Command
-----------------------------------------------
1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.amzn2.0.1.x86_64/jre/bin/java)
* 2 /usr/lib/jvm/java-17-amazon-corretto.x86_64/bin/java
+ 3 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.23.0.9-2.amzn2.0.1.x86_64/bin/java)
刚刚运行了它jenkins
并返回/usr/bin/jenkins