Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-28294

"JDK 5 not supported with Maven" error with JDK 6

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Trivial Trivial
    • maven-plugin
    • jenkins: 1.612
      maven2: 2.2.1
      maven plugin: 2.9
      Ubuntu 14.04.2 LTS
      openjdk-6-6b35-1.13.7
      openjdk-7-7u79-2.5.5

      When building a project that uses Maven, an error is encountered that states that Maven and JDK 5 are not compatible. However, the JDK version that was invoked is very obviously Java 6. Worse, the Maven plugin then increments the JDK version to JDK 7, which is also available on the system.

      [main] $ /usr/lib/jvm/java-6-openjdk-amd64//bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven-agent-1.6.jar:/usr/share/maven2/boot/classworlds.jar hudson.maven.agent.Main /usr/share/maven2/ /var/cache/jenkins/war/WEB-INF/lib/remoting-2.51.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven-interceptor-1.6.jar 56940
      <===[JENKINS REMOTING CAPACITY]===>channel started
      ERROR: JENKINS-18403 JDK 5 not supported to run Maven; retrying with slave Java and setting compile/test properties to point to /usr/lib/jvm/java-6-openjdk-amd64/
      [main] $ /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven-agent-1.6.jar:/usr/share/maven2/boot/classworlds.jar hudson.maven.agent.Main /usr/share/maven2/ /var/cache/jenkins/war/WEB-INF/lib/remoting-2.51.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven-interceptor-1.6.jar 34098

      This is not reproducible from the command line; building a project from the same pom.xml and same maven2 build and same JDK will result in a proper build.

          [JENKINS-28294] "JDK 5 not supported with Maven" error with JDK 6

          Daniel Beck added a comment -

          Again, the issue is Maven Plugin's tight integration of Jenkins and Maven. Jenkins' remoting model requires that all slaves run in compatible JRE's, and this appears to extend to Maven Project plugin builds.

          While the error message appears to be outdated now,
          https://github.com/jenkinsci/maven-plugin/blob/0963b19fef1cb3fbc9da2fa10649c9970b12f4a7/src/main/java/hudson/maven/AbstractMavenProcessFactory.java#L289
          the basic requirement is there by design.

          If you want to build projects using any JDK just like on the command line, use Freestyle projects. You'll lose the tight integration, but that's the cause of this problem anyway. Keeping this open for the outdated message, the rest is by design.

          If you object to the automatic JDK upgrade implemented as a fallback, please file an improvement request that this be configurable or removed (whichever you prefer).

          Daniel Beck added a comment - Again, the issue is Maven Plugin's tight integration of Jenkins and Maven. Jenkins' remoting model requires that all slaves run in compatible JRE's, and this appears to extend to Maven Project plugin builds. While the error message appears to be outdated now, https://github.com/jenkinsci/maven-plugin/blob/0963b19fef1cb3fbc9da2fa10649c9970b12f4a7/src/main/java/hudson/maven/AbstractMavenProcessFactory.java#L289 the basic requirement is there by design. If you want to build projects using any JDK just like on the command line, use Freestyle projects. You'll lose the tight integration, but that's the cause of this problem anyway. Keeping this open for the outdated message, the rest is by design. If you object to the automatic JDK upgrade implemented as a fallback, please file an improvement request that this be configurable or removed (whichever you prefer).

          Daniel Beck added a comment -

          FWIW at JUC this week I talked to Kohsuke about this. He said that Maven Projects requiring a JDK for building that is able to run the version of Jenkins that invokes it is a limitation in the basic design of Maven Plugin and cannot be changed.

          Daniel Beck added a comment - FWIW at JUC this week I talked to Kohsuke about this. He said that Maven Projects requiring a JDK for building that is able to run the version of Jenkins that invokes it is a limitation in the basic design of Maven Plugin and cannot be changed.

          jergan added a comment -

          This problem does not seem to be limited to Maven2. I see the same using Maven 3.3.3.

          <copy of log>
          Started by user anonymous
          Building in workspace /local1/program/jenkins/jenkins_home/workspace/eedb-nightly
          Updating http://wgba-subversion.westerngeco.slb.com/subversion/trunk/projects/eedb at revision '2015-08-18T08:21:36.623 +0000'
          At revision 52855
          no change for http://wgba-subversion.westerngeco.slb.com/subversion/trunk/projects/eedb since the previous build
          Parsing POMs
          [eedb-nightly] $ /local1/program/jdk/jdk1.6.0_31/bin/java -server -Xmx1024M -XX:MaxPermSize=512m -cp /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.4.jar:/local1/program/apache-maven-3.3.3/boot/plexus-classworlds-2.5.2.jar:/local1/program/apache-maven-3.3.3/conf/logging jenkins.maven3.agent.Maven31Main /local1/program/apache-maven-3.3.3 /local1/program/apache-tomcat-7.0.30/webapps/jenkins/WEB-INF/lib/remoting-2.52.jar /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.4.jar /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.4.jar 48996
          <===[JENKINS REMOTING CAPACITY]===>channel started
          ERROR: JENKINS-18403 JDK 5 not supported to run Maven; retrying with slave Java and setting compile/test properties to point to /local1/program/jdk/jdk1.6.0_31
          [eedb-nightly] $ /local1/program/jdk/jdk1.7.0_79/jre/bin/java -server -Xmx1024M -XX:MaxPermSize=512m -cp /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.4.jar:/local1/program/apache-maven-3.3.3/boot/plexus-classworlds-2.5.2.jar:/local1/program/apache-maven-3.3.3/conf/logging jenkins.maven3.agent.Maven31Main /local1/program/apache-maven-3.3.3 /local1/program/apache-tomcat-7.0.30/webapps/jenkins/WEB-INF/lib/remoting-2.52.jar /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.4.jar /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.4.jar 46945
          <===[JENKINS REMOTING CAPACITY]===>channel started
          Executing Maven: -B -f /local1/program/jenkins/jenkins_home/workspace/eedb-nightly/pom.xml clean install site site:deploy
          [INFO] Scanning for projects...
          </copy of log>

          jergan added a comment - This problem does not seem to be limited to Maven2. I see the same using Maven 3.3.3. <copy of log> Started by user anonymous Building in workspace /local1/program/jenkins/jenkins_home/workspace/eedb-nightly Updating http://wgba-subversion.westerngeco.slb.com/subversion/trunk/projects/eedb at revision '2015-08-18T08:21:36.623 +0000' At revision 52855 no change for http://wgba-subversion.westerngeco.slb.com/subversion/trunk/projects/eedb since the previous build Parsing POMs [eedb-nightly] $ /local1/program/jdk/jdk1.6.0_31/bin/java -server -Xmx1024M -XX:MaxPermSize=512m -cp /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.4.jar:/local1/program/apache-maven-3.3.3/boot/plexus-classworlds-2.5.2.jar:/local1/program/apache-maven-3.3.3/conf/logging jenkins.maven3.agent.Maven31Main /local1/program/apache-maven-3.3.3 /local1/program/apache-tomcat-7.0.30/webapps/jenkins/WEB-INF/lib/remoting-2.52.jar /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.4.jar /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.4.jar 48996 <=== [JENKINS REMOTING CAPACITY] ===>channel started ERROR: JENKINS-18403 JDK 5 not supported to run Maven; retrying with slave Java and setting compile/test properties to point to /local1/program/jdk/jdk1.6.0_31 [eedb-nightly] $ /local1/program/jdk/jdk1.7.0_79/jre/bin/java -server -Xmx1024M -XX:MaxPermSize=512m -cp /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.4.jar:/local1/program/apache-maven-3.3.3/boot/plexus-classworlds-2.5.2.jar:/local1/program/apache-maven-3.3.3/conf/logging jenkins.maven3.agent.Maven31Main /local1/program/apache-maven-3.3.3 /local1/program/apache-tomcat-7.0.30/webapps/jenkins/WEB-INF/lib/remoting-2.52.jar /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.4.jar /local1/program/jenkins/jenkins_home/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.4.jar 46945 <=== [JENKINS REMOTING CAPACITY] ===>channel started Executing Maven: -B -f /local1/program/jenkins/jenkins_home/workspace/eedb-nightly/pom.xml clean install site site:deploy [INFO] Scanning for projects... </copy of log>

          Sorry, but for me this issue is absolutely not trivial, I have a lot of tasks that need java 1.6 and it is not possible, for me, use the free style job or revert to version 1.611, if not exist a work-around the trivial priority is no correct, please update. I use maven 3.0.5

          Massimo Fabriani added a comment - Sorry, but for me this issue is absolutely not trivial, I have a lot of tasks that need java 1.6 and it is not possible, for me, use the free style job or revert to version 1.611, if not exist a work-around the trivial priority is no correct, please update. I use maven 3.0.5

          Daniel Beck added a comment -

          maxfab As I wrote above, I got confirmation by Kohsuke that Maven Project Plugin fundamentally does not support older JDKs that are no longer supported by Jenkins itself. This is by design.

          Since we're already relying on Java 7 in Jenkins (which is already EOL'ed as well, by the way, so we're definitely not on the bleeding edge here), your only options really are to stay on the last supported Jenkins release (the 1.609.x LTS release line works with Java 6), or switch to a different project type – at least for the foreseeable future.


          The issue priority reflects what's left to be resolved in this issue – that the error message should not mention JDK 5 when the problem is actually JDK 6.

          Daniel Beck added a comment - maxfab As I wrote above, I got confirmation by Kohsuke that Maven Project Plugin fundamentally does not support older JDKs that are no longer supported by Jenkins itself. This is by design. Since we're already relying on Java 7 in Jenkins (which is already EOL'ed as well, by the way, so we're definitely not on the bleeding edge here), your only options really are to stay on the last supported Jenkins release (the 1.609.x LTS release line works with Java 6), or switch to a different project type – at least for the foreseeable future. The issue priority reflects what's left to be resolved in this issue – that the error message should not mention JDK 5 when the problem is actually JDK 6.

          Here is the PR for this : https://github.com/jenkinsci/maven-plugin/pull/58

          Based on the discussion here I just updated the error message but not the behavior.

          Before:

          ERROR: [JENKINS-18403] JDK 5 not supported to run Maven; retrying with slave Java and setting compile/test properties to point to /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
          

          After:

          ERROR: [JENKINS-18403][JENKINS-28294] JDK 'java-1.6' not supported to run Maven projects; retrying with slave Java and setting compile/test properties to point to /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home. Maven projects have to be launched with a Java version greater or equal to the one used by the slave. Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK.
          

          Arnaud Héritier added a comment - Here is the PR for this : https://github.com/jenkinsci/maven-plugin/pull/58 Based on the discussion here I just updated the error message but not the behavior. Before: ERROR: [JENKINS-18403] JDK 5 not supported to run Maven; retrying with slave Java and setting compile/test properties to point to /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home After: ERROR: [JENKINS-18403][JENKINS-28294] JDK 'java-1.6' not supported to run Maven projects; retrying with slave Java and setting compile/test properties to point to /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home. Maven projects have to be launched with a Java version greater or equal to the one used by the slave. Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK.

          There is a workaround to this problem. From my experience with Jenkins ver. 1.629 (already on JDK 1.7), it looks like the issue only occurs when you create a new job using ‘Maven project’ template.

          If you create a ‘Freestyle’ or ‘Multi-configuration’ project and configure Maven using ‘Invoke top-level Maven targets’ or ‘Invoke Maven 3’ build step, everything works fine.

          I successfully tested with JDK 1.5 and 1.6 added to the main Jenkins config, which made them available in a JDK drop-down list of the job configuration. Note my Jenkins is running on JDK 1.7.

          Therefore, I believe that the original problem is a Jenkins bug.

          I can’t imagine why Jenkins would’ve prevented use of older JDKs in a project build, provided you can successfully built the project from the command line – it’s a tool after all.
          Java 7 requirement from version 1.612 is a different matter related to running Jenkins itself.

          Robert Zaczynski added a comment - There is a workaround to this problem. From my experience with Jenkins ver. 1.629 (already on JDK 1.7), it looks like the issue only occurs when you create a new job using ‘Maven project’ template. If you create a ‘Freestyle’ or ‘Multi-configuration’ project and configure Maven using ‘Invoke top-level Maven targets’ or ‘Invoke Maven 3’ build step, everything works fine. I successfully tested with JDK 1.5 and 1.6 added to the main Jenkins config, which made them available in a JDK drop-down list of the job configuration. Note my Jenkins is running on JDK 1.7. Therefore, I believe that the original problem is a Jenkins bug. I can’t imagine why Jenkins would’ve prevented use of older JDKs in a project build, provided you can successfully built the project from the command line – it’s a tool after all. Java 7 requirement from version 1.612 is a different matter related to running Jenkins itself.

          Yes we are agree rzacz It is working with FreeStyle or Multi configuration jobs
          The problem is only in Maven Jobs because its "advanced" jenkins/maven integration relies on the exchange of java serialized classes between the jenkins master JVM and the Maven one. Because of this Maven Jobs cannot run on a java version < to the version with which Jenkins core is compiled.
          Thus it is a bug, or a technical limitation ... but not easy to solve
          I tried to document this a little bit on our CloudBees side : https://cloudbees.zendesk.com/hc/en-us/articles/217517477-Maven-jobs-and-Java-versions-compatibility
          Maybe I could just copy it in the Maven Job wiki page but I'm not sure that people will read it more

          Arnaud Héritier added a comment - Yes we are agree rzacz It is working with FreeStyle or Multi configuration jobs The problem is only in Maven Jobs because its "advanced" jenkins/maven integration relies on the exchange of java serialized classes between the jenkins master JVM and the Maven one. Because of this Maven Jobs cannot run on a java version < to the version with which Jenkins core is compiled. Thus it is a bug, or a technical limitation ... but not easy to solve I tried to document this a little bit on our CloudBees side : https://cloudbees.zendesk.com/hc/en-us/articles/217517477-Maven-jobs-and-Java-versions-compatibility Maybe I could just copy it in the Maven Job wiki page but I'm not sure that people will read it more

          Code changed in jenkins
          User: Arnaud Heritier
          Path:
          src/main/java/hudson/maven/AbstractMavenProcessFactory.java
          http://jenkins-ci.org/commit/maven-plugin/81dd5ee4eb76ce1b8f41fde753ca5c46d52cd4be
          Log:
          [fix JENKINS-28294] Improve the ERROR message when a Maven project is launched with a java version < to the minimum version required by the master. (#58)

          Examples:

          • Jenkins >= 1.612 requires Java 7 thus Maven jobs must be launched with Java >= 7
          • Jenkins >= 1.520 requires Java 6 thus Maven jobs must be launched with Java >= 6

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Arnaud Heritier Path: src/main/java/hudson/maven/AbstractMavenProcessFactory.java http://jenkins-ci.org/commit/maven-plugin/81dd5ee4eb76ce1b8f41fde753ca5c46d52cd4be Log: [fix JENKINS-28294] Improve the ERROR message when a Maven project is launched with a java version < to the minimum version required by the master. (#58) Examples: Jenkins >= 1.612 requires Java 7 thus Maven jobs must be launched with Java >= 7 Jenkins >= 1.520 requires Java 6 thus Maven jobs must be launched with Java >= 6

          New error is

          ERROR: ================================================================================
          ERROR: Invalid project setup: hudson/maven/AbstractMavenProcessFactory$ConfigureOriginalJDK : Unsupported major.minor version 51.0
          ERROR: [JENKINS-18403][JENKINS-28294] JDK 'j6' not supported to run Maven projects.
          ERROR: Maven projects have to be launched with a Java version greater or equal to the minimum version required by the master.
          ERROR: Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK.
          ERROR: Retrying with slave Java and setting compile/test properties to point to /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/.
          ERROR: ================================================================================
          

          Fixed in maven-plugin >= 2.14

          Arnaud Héritier added a comment - New error is ERROR: ================================================================================ ERROR: Invalid project setup: hudson/maven/AbstractMavenProcessFactory$ConfigureOriginalJDK : Unsupported major.minor version 51.0 ERROR: [JENKINS-18403][JENKINS-28294] JDK 'j6' not supported to run Maven projects. ERROR: Maven projects have to be launched with a Java version greater or equal to the minimum version required by the master. ERROR: Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK. ERROR: Retrying with slave Java and setting compile/test properties to point to /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/. ERROR: ================================================================================ Fixed in maven-plugin >= 2.14

            aheritier Arnaud Héritier
            karlkatzke Karl Katzke
            Votes:
            23 Vote for this issue
            Watchers:
            30 Start watching this issue

              Created:
              Updated:
              Resolved: