-
Bug
-
Resolution: Fixed
-
Trivial
-
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
-
Powered by SuggestiMate
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-18403JDK 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.
- is duplicated by
-
JENKINS-28481 JDK 5 not supported to run Maven since Jenkins 1.612
-
- Resolved
-
-
JENKINS-28368 Error "JDK 5 not supported to run Maven" while running Java 6
-
- Resolved
-
[JENKINS-28294] "JDK 5 not supported with Maven" error with JDK 6
I can successfully build the project, with the same POM file, using a "Freestyle Project" – the error above only happens if I am using a "Maven Project"
I can also reproduce this with maven-project-plugin 2.8 and 2.9 using Maven 3.2 and Oracle JDKs.
Jenkins 1.612 moved to a Java 6 requirement as you can see in the changelog, it's possible this is just the wrong error message with the '5' hard-coded. Since the (mis)design of the Maven Project Plugin results in tight integration between Maven and Jenkins, it wouldn't be surprising if you were now unable to run builds with JDK 6 or earlier with it without additional effort.
I completely agree with you, Daniel, but it's not the error message – it's the automatic upgrading to JDK 7 that is the bug.
To clarify, this issue is primarily about the feature that says:
retrying with slave Java and setting compile/test properties to point to
?
Daniel: The first attempt to build using this JDK:
/usr/lib/jvm/java-6-openjdk-amd64//bin/java
Results in an error about JDK5.
It then results in a build that attempts using this JDK:
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
This means there are two bugs:
- JDK 5 is not allowed, but JDK 6 should be.
- When JDK 6 is selected, it should not attempt to build using JDK7, which isn't even configured as an available JDK in Jenkins.
JDK 5 is not allowed, but JDK 6 should be.
As I wrote, Maven jobs are tightly integrated with Jenkins, and since Jenkins raised the Java runtime requirement to 7, it's possible this was changed as well (and it's just the message that wasn't adjusted to reflect this)
which isn't even configured as an available JDK in Jenkins
The message (and code) indicates this is actually a deliberate feature. Not sure what to do about this.
I'm not sure, either, but it sure as heck breaks building a Java 6 Maven project with Jenkins. I realize that JDK 6 and JDK 7 are both end of life. But - breaking backwards compatibility like that means that we would need to maintain two completely separate build environments as we start to port our JDK 6 projects to JDK 8 over the next year.
That's one of the major downsides to building with the Maven Plugin. Another:
http://javaadventure.blogspot.de/2013/11/jenkins-maven-job-type-considered-evil.html (Stephen is both a Maven and Jenkins developer)
If you were using a freestyle job with a Maven build step you wouldn't have the nice per-module reporting and such, but it would work independent of the JRE used to run Jenkins.
We have the same problem here when trying to use the IBM JDK. Is it possible that the Maven plugin makes a confusion between Maven 3.3.X that requires Java 7 and 3.2.X that is OK with Java 6?
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).
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.
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
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.
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
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
I can also reproduce this with maven-project-plugin 2.7.1.