java.lang.UnsupportedClassVersionError: hudson/remoting/Launcher 由较新版本的 Java 运行时编译(类文件版本 61.0),此 Java 运行时仅识别最高版本 55.0 的类文件
java.lang.UnsupportedClassVersionError: hudson/remoting/Launcher has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
ID: cicd/jenkins-agent-java-version-mismatch
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Jenkins 2.440 | active | — | — | — |
| Jenkins 2.450 | active | — | — | — |
| Java 11 | active | — | — | — |
| Java 17 | active | — | — | — |
| Java 21 | active | — | — | — |
根因分析
Jenkins agent 运行较旧版本的 Java(例如 Java 11),而 Jenkins 控制器运行较新版本(例如 Java 17),导致 remoting jar 不兼容。
English
Jenkins agent is running an older Java version (e.g., Java 11) than the Jenkins controller (e.g., Java 17), causing remoting jar incompatibility.
官方文档
https://www.jenkins.io/doc/administration/requirements/java/解决方案
-
On the Jenkins agent, install Java 17 or later matching the controller's version. Update JAVA_HOME and restart the agent service. For Linux: sudo apt install openjdk-17-jre && sudo systemctl restart jenkins-agent
-
Use the 'WebSocket' agent connection mode instead of TCP: In Jenkins controller, configure the agent to use WebSocket (under Advanced > WebSocket). This bypasses some class version checks.
无效尝试
常见但无效的做法:
-
80% 失败
Updating the agent.jar file manually without updating the Java runtime still fails because the agent JVM is too old.
-
90% 失败
Setting JAVA_HOME on the agent to a Java 8 installation makes the error worse as the version gap increases.
-
70% 失败
Restarting the Jenkins controller does not affect agent Java versions; the agent must be upgraded independently.