Maven jobs and Java versions compatibility Arnaud Héritier July 13, 2022 12:08 Updated The content of this article has moved to the new documentation site. Related articles Context How to config a Maven Toolchain Why is my instance not getting the right information from CloudBees Update Center starting on October 19th, 2021? How to set several JDK versions to be installed on demand After ugrading Java to JDK 11, Jenkins fails to start due to Unrecognized VM option Comments 7 comments Sort by Date Votes Bollapu Harinathareddy January 10, 2017 06:56 Hi, I am facing similar issue in Jenkins 2.18 version, will you please is this solution will work or not. I am using maven 3.3.3 and JDK 1.8. Thanks in advance Harinatha 0 Arnaud Héritier January 10, 2017 14:18 Hi Bollapu, Yes the principle remains the same. If you have this error this is because you configured a Maven job with a Java version < 7. Jenkins >= 1.612 and thus 2.18 cannot natively use Maven jobs with a Java version inferior to 7. THus the build is trying to use the Java version of your agent which is necessarily superior or equal to 7. Best regards 0 Oleg Nenashev July 27, 2017 08:18 This guide is a bit outdated. If you use CJE based on Jenkins LTS 2.60.x or newer, Java 8 is required in the case of Maven Jobs. It is documented on the plugin Wiki page: https://wiki.jenkins.io/display/JENKINS/Maven+Project+Plugin 0 Arnaud Héritier September 14, 2017 09:15 It was fixed Oleg. Thanks 0 Fenix32 Gonz January 04, 2018 14:31 Edited Hi, I am updating from Jenkins 1.624.4 to 2.89.2 with my projects on JDK1.6. In my poms <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> I made them work creating new FreeStyle-Jobs configured as JDK1.6 without -Dmaven.compiler.source=1.6 -Dmaven.compiler.target=1.6. I have some questions Is it necessary/recommendable to continue with The toolchains solution? Could I use Maven-Jobs instead FreeStyle-Jobs after apply The toolchains solution? Thank you a lot for the tutorial and the help ^_^ 0 Arnaud Héritier January 04, 2018 22:32 Hi Fenix, As you configured the maven compiler in the pom you effectively don't need to use -Dmaven.compiler.source=1.6 -Dmaven.compiler.target=1.6 No the toolchain solution isn't mandatory and is useful only if you want to come back to use Maven-Jobs instead FreeStyle-Jobs. By using toolchains you'll be able to use Maven-Jobs by letting them running on Java 8 (required by jenkins) but all tools (javac, javadocs, ...) will use Java 6. Using a freestyle project with Java 6 give you the same result if you don't need absolutely some features provided by the Maven jobs. BR. 0 Jesse Glick July 01, 2022 11:41 The resolution All Maven Jobs have to be configured to use at the minimum the version required by Jenkins is incorrect. The whole point of the message printed in the build log Retrying with slave Java and setting compile/test properties to point to <path_to_the_java_vm-used_by_your_slave>. is that you do not have to do anything, in the common case: if your Maven project is configured with a JDK older than the minimum currently required by Jenkins controllers & agents, then the Maven plugin for Jenkins will automatically relaunch the Maven JVM with a newer Java runtime but configure common Maven mojos to actually use your configured JDK for build steps. This automated workaround may not be complete, depending on the details of your project. See https://issues.jenkins.io/browse/JENKINS-68878?focusedCommentId=427502&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-427502 for a case where a JAX-WS issue in Jenkins 2.357 (requiring Java 11) was resolved by updating a mojo version in the POM. When you have time to do it, the recommendation is to switch to Pipeline. https://plugins.jenkins.io/pipeline-maven/ provides much of the functionality of the Maven plugin for Jenkins in a more sustainable way. 0 Please sign in to leave a comment.