Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported major.minor version 52.0 - trying to look for Java 8, which is already set in Java_home and Path

I am trying to run my automation code built in cucumber framework by Jenkins job, in which environment variables are set by injecting via build setup. I am getting the following error.

[EnvInject] - Executing scripts and injecting environment variables after the SCM step.
[EnvInject] - Injecting as environment variables the properties content 
PATH=/data/java/jdk180152/bin:/data/build_tools/maven/apache-maven-3.5.2/bin:/data/build_tools/python/python-2.7.14/bin/:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:
M2_HOME=/data/build_tools/maven/apache-maven-3.5.2
JDK_HOME=/data/java/jdk180152
JAVA_HOME=/data/java/jdk180152
MAVEN_HOME=/data/build_tools/maven/apache-maven-3.5.2

[EnvInject] - Variables injected successfully.
Parsing POMs
Established TCP socket on 33831
[cafeAutomation] $ java -cp /data/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.12-alpha-1.jar:/data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven-3.5.2/boot/plexus-classworlds-2.5.2.jar:/data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven-3.5.2/conf/logging jenkins.maven3.agent.Maven35Main /data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven-3.5.2 /var/cache/jenkins/war/WEB-INF/lib/remoting-3.14.jar /data/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.12-alpha-1.jar /data/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12-alpha-1.jar 33831
Exception in thread "main" java.lang.UnsupportedClassVersionError: hudson/remoting/Launcher : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:442)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:64)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:354)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
    at jenkins.maven3.agent.Maven35Main.main(Maven35Main.java:133)
    at jenkins.maven3.agent.Maven35Main.main(Maven35Main.java:64)
ERROR: ================================================================================
ERROR: Invalid project setup: Connection reset
ERROR: Processing failed due to a bug in the code. Please report this to the issue tracker (https://jenkins.io/redirect/report-an-issue).
java.lang.NullPointerException
    at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:304)
    at hudson.maven.ProcessCache.get(ProcessCache.java:236)
    at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:804)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
    at hudson.model.Run.execute(Run.java:1724)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:421)
project=hudson.maven.MavenModuleSet@6b7062ed[smr-qa-maven]
project.getModules()=[hudson.maven.MavenModule@10ea4a41[smr-qa-maven/cafeAutomatin:cafeAutomation][smr-qa-maven/cafeAutomation:cafeAutomation][relativePath:WebApp/Automation Scripts/CAFE Automation Scripts/cafeAutomation]]
project.getRootModule()=hudson.maven.MavenModule@10ea4a41[smr-qa-maven/cafeAutomation:cafeAutomation][smr-qa-maven/cafeAutomation:cafeAutomation][relativePath:WebApp/Automation Scripts/CAFE Automation Scripts/cafeAutomation]
FATAL: null

Java version installed on the box - Java 8, Maven - 3.5.2, Jenkins version - 2.89.3

In my pom.xml file, I have mentioned the plugin as

<plugin>

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>

<configuration>
<compilerVersion>1.8</compilerVersion>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
                    <executable>/data/java/jdk180152/bin/javac</executable>

</configuration>
</plugin>

Have also tried by adding the following to the pom file, but still the same error

<properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
like image 369
AutomationTester Avatar asked Feb 01 '18 18:02

AutomationTester


2 Answers

I have run into the same problem. It was anoying because I was trying to build an existing project which was not changed since over one year. I always got following error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: hudson/remoting/Launcher : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
    at jenkins.maven3.agent.Maven33Main.main(Maven33Main.java:133)
    at jenkins.maven3.agent.Maven33Main.main(Maven33Main.java:64)
ERROR: ================================================================================
ERROR: Invalid project setup: Connection reset
ERROR: [JENKINS-18403][JENKINS-28294] JDK 'JDK7' 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 /var/tomcat/java/jdk7/.
ERROR: ================================================================================

Some one from OPS team had updated jeikins version and that is the clue! I came around following site Maven jobs and Java versions compatibility. The problem is very well described on that site by one sentense:

Because java serialized classes are exchanged between Jenkins master and Maven Jobs it is required that the JVM used to launch Maven is superior or equal to the version of Java for which Jenkins Master is built for.

I opened my Jenkins project and changed the "JDK" settings. After changing the java version (in my case to Java 8) everything was fine and my project was building successfully.

like image 105
kleenxcoder Avatar answered Oct 12 '22 12:10

kleenxcoder


Well I don't know if this is a correct answer or a workaround. I didn't had permissions to go to Manage Jenkins. When the admin user set the JDK through Manage Jenkins option, everything worked fine.

like image 40
AutomationTester Avatar answered Oct 12 '22 11:10

AutomationTester