A Maven build is failing with ERROR: Failed to parse POMs …​ Unsupported major.minor version 51.0

Article ID:205311740
1 minute readKnowledge base

Issue

  • A Maven build is failing with an error like

ERROR: Failed to parse POMs
...
Caused by: java.lang.UnsupportedClassVersionError: org/apache/maven/eventspy/EventSpy : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
...

Resolution

Apache Maven 3.3.x requires a minimum of Java 7 and your build is configured to use Java 6.

Either install and configure your job to use a version of Maven < 3.3 or install and configure your job to use a version of JDK > 6 to solve the issue. The Configuration Slicing Plugin will help you to easily change the version of Apache Maven or the JDK used in several jobs in one step.

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.