Maven - Unsupported major.minor version of surefire
Yesterday, I tried to set one of my maven Java projects to be deployed by travis-ci using JDK-7 and I faced issues in surefire plugin:
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)
Surefire plugin seems to use by default the default JDK used to run the build for compiling test cases. In my case it was JDK-6. To make it run on new JDK, I made following changes inside my pom.xml
<build>
    <finalName>jdk7</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <showDeprecation>true</showDeprecation>
                <showWarnings>true</showWarnings>
                <executable>${env.JAVA_HOME}/bin/javac</executable>
                <fork>true</fork>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <jvm>${env.JAVA_HOME}/bin/java</jvm>
            </configuration>
        </plugin>
    </plugins>
</build>Written by Hélio Cabral Medeiros
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
 #Maven 
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#