The root cause of the problem seems to be:
Bad version number in .class file; nested exception is
java.lang.UnsupportedClassVersionError

This usually happens when you're running an older JVM with a Jar file
that was compiled with/against a much newer one. But you claim that
you're running JDK 1.6, so I have no idea what's going on. Are you
sure you're running 1.6?

Wayne

On 2/13/08, Toni Heimala <[EMAIL PROTECTED]> wrote:
> I have tried defining versions 2.3, 2.4 and 2.4.1. They all give the
> same output. If I don't define a version for the surefire plugin, then
> it uses some old version which is not compliant with JUnit 4.x, which
> causes the tests to fail (because @Before is not run).
>
> Maven version: 2.0.8
> Surefire Plugin Version: 2.3 - 2.4.1
> JUnit version: 4.0 - 4.4
> JDK Version: 1.5 - 1.6
>
> -- <MavenSurefireProblemTest.java> --
>
> package maven;
>
> import static org.junit.Assert.*;
>
> import org.junit.Before;
> import org.junit.Test;
>
> public class MavenSurefireProblemTest
> {
>      private String foo;
>
>      @Before
>      public void setUp() throws Exception
>      {
>          foo = new String("FOO!");
>      }
>
>      @Test
>      public void testFoo()
>      {
>          System.out.println("Result: " + foo);
>          assertNotNull(foo);
>      }
> }
>
> -- </MavenSurefireProblemTest.java> --
>
> -- <pom.xml> --
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project>
>    <modelVersion>4.0.0</modelVersion>
>    <groupId>JavaProblems</groupId>
>    <artifactId>JavaProblems</artifactId>
>    <version>0.0.1</version>
>    <build>
>      <plugins>
>        <plugin>
>          <artifactId>maven-compiler-plugin</artifactId>
>          <configuration>
>            <source>1.5</source>
>            <target>1.5</target>
>          </configuration>
>        </plugin>
>        <plugin>
>               <artifactId>maven-surefire-plugin</artifactId>
>               <groupId>org.apache.maven.plugins</groupId>
>               <version>2.4.1</version></plugin>
>      </plugins>
>    </build>
>    <dependencies>
>      <dependency>
>        <groupId>junit</groupId>
>        <artifactId>junit</artifactId>
>        <version>4.4</version>
>        <scope>test</scope>
>      </dependency>
>    </dependencies>
> </project>
>
> -- </pom.xml> --
>
> -- <mvn test> --
>
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building Unnamed - JavaProblems:JavaProblems:jar:0.0.1
> [INFO]    task-segment: [test]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] [resources:resources]
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [compiler:compile]
> [INFO] Nothing to compile - all classes are up to date
> [INFO] [resources:testResources]
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [compiler:testCompile]
> [INFO] Nothing to compile - all classes are up to date
> [INFO] [surefire:test]
> [INFO] Surefire report directory:
> C:\toni\work\projects\JavaProblems\target\surefire-reports
> org.apache.maven.surefire.booter.SurefireExecutionException: Bad version
> number in .class file; nested exception is
> java.lang.UnsupportedClassVersionError: Bad version number in .class file
> java.lang.UnsupportedClassVersionError: Bad version number in .class file
>          at java.lang.ClassLoader.defineClass1(Native Method)
>          at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
>          at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
>          at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
>          at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
>          at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
>          at java.security.AccessController.doPrivileged(Native Method)
>          at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>          at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
>          at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>          at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:87)
>          at
> org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)
>          at org.apache.maven.surefire.Surefire.run(Surefire.java:156)
>          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>          at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>          at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>          at java.lang.reflect.Method.invoke(Method.java:585)
>          at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
>          at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] There are test failures.
>
> Please refer to
> C:\toni\work\projects\JavaProblems\target\surefire-reports for t
> he individual test results.
> [INFO]
> ------------------------------------------------------------------------
> [INFO] For more information, run Maven with the -e switch
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 16 seconds
> [INFO] Finished at: Wed Feb 13 16:42:34 EET 2008
> [INFO] Final Memory: 6M/11M
> [INFO]
> ------------------------------------------------------------------------
>
> -- </mvn test> --
>
> Rerpot with: mvn -X test
> Is included as an attachment.
>
> --
> Toni Heimala
> Image Soft Oy
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to