Common error in Hybris code build process in local setup when we have set wrong java version

Some time, we have  installed multiple java version in Mac like Java 1.8 and java 11.0  and default version is java 8 but we are trying to start ant clean or ant all with above Hybris Sap commence 2205 version.  We will have below error due to wrong java version.

/Volumes/work/cmpe/et-commerce/core-customize/hybris/bin/platform/build.xml:9: The following error occurred while executing this line:
/Volumes/work/cmpe/et-commerce/core-customize/hybris/bin/platform/resources/ant/antmacros.xml:50: java.lang.UnsupportedClassVersionError: de/hybris/ant/taskdefs/gradle/GenerateGradleProjectTask 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
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at org.apache.tools.ant.AntClassLoader.defineClassFromData(AntClassLoader.java:1153)
at org.apache.tools.ant.AntClassLoader.getClassFromStream(AntClassLoader.java:1321)
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1373)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1338)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1093)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:569)
at org.apache.tools.ant.taskdefs.Definer.loadProperties(Definer.java:401)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:263)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:173)
at org.apache.tools.ant.taskdefs.ImportTask.importResource(ImportTask.java:221)
at org.apache.tools.ant.taskdefs.ImportTask.execute(ImportTask.java:165)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:184)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:104)
at org.apache.tools.ant.Main.runBuild(Main.java:802)
at org.apache.tools.ant.Main.startAnt(Main.java:223)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)

Open Terminal in Mac and check java version using “Java -version” command.  You can see above. its was expected java 11 in Hybirs 2205  but default set to Java 8 which is not compatibility that why there was build failed.  You can refer to how to set default Java version.

Leave a Comment

Your email address will not be published. Required fields are marked *