JENKINS_JAVA_VERSION cicd runtime_error ai_generated true

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

Also available as: JSON · Markdown · 中文
85%Fix Rate
90%Confidence
1Evidence
2023-06-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Jenkins 2.440 active
Jenkins 2.450 active
Java 11 active
Java 17 active
Java 21 active

Root Cause

Jenkins agent is running an older Java version (e.g., Java 11) than the Jenkins controller (e.g., Java 17), causing remoting jar incompatibility.

generic

中文

Jenkins agent 运行较旧版本的 Java(例如 Java 11),而 Jenkins 控制器运行较新版本(例如 Java 17),导致 remoting jar 不兼容。

Official Documentation

https://www.jenkins.io/doc/administration/requirements/java/

Workarounds

  1. 90% success 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
    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
  2. 75% success 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.
    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.

中文步骤

  1. 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
  2. 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.

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Updating the agent.jar file manually without updating the Java runtime still fails because the agent JVM is too old.

  2. 90% fail

    Setting JAVA_HOME on the agent to a Java 8 installation makes the error worse as the version gap increases.

  3. 70% fail

    Restarting the Jenkins controller does not affect agent Java versions; the agent must be upgraded independently.