We have upgraded the Jenkins version from 2.332.1 to 2.375.4. Getting the below error only for Maven Project types while referenced JDK 8 in the build jobs.
java.lang.UnsupportedClassVersionError: hudson/remoting/Launcher has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0.
In Code, we are still using Java 8. Able to use JDK 8 in Freestyle and pipeline jobs. Why its expecting Java 11 only for Maven Projects build. Please share the suggestions for this issue.
The maven job type is a poor choice because it requires that the job must run with the same JVM version as the agent is running. When Jenkins requires Java 17 (as it will in some future day), the maven job type will then run the jobs with Java 17. More details are in the linked article and in the links that are included in the article.
Maven documentation says the tool chain plugin approach should work. But when we try this approach it is not working still when we try to compile using java 8. Do you have any other suggestions to work such that for a shorter period we can live with Maven build jobs and Jenkins security vulnerability also will be remediated?
I suspect that means there is a mistake in your configuration somewhere. I build maven jobs very frequently with different versions of Java using Pipeline jobs. Investigate the failure and fix the configuration error. There are thousands of Jenkins controllers running jobs with multiple versions of Java and multiple versions of maven. I’m confident you can find a way to let your controller do it too.
There isn’t a way to give you both the things you requested. Security vulnerabilities for Jenkins core are remediated only in the most recent weekly and the most recent LTS. The most recent weekly and the most recent LTS both require Java 11 or newer.
I think i should have explained well, we have not changed the maven build jobs to Pipeline jobs. Before we move to Pipeline jobs with the existing Maven build projects we would like to do this approach (tool chain plugin). Hope it is feasible we think, we will try out further based on the documentation provided by Maven.