Maven jaxws plugin fails with java.lang.UnsupportedClassVersionError: Bad version number in .class file

580 views Asked by At

I am trying to compile an old project that uses JDK 1.5.0_13 with Maven 2.2.1.

The 'jaxws-maven-plugin' fails with this message:

[INFO] Processing: com.xyzzy.sydemas.facade.SydemasFacadeImpl
[INFO] jaxws:wsgen args: [-keep, -s, C:\Development\www\workspace\sydemas_ws_sei\target\generated-sources\wsgen, -d, C:\Development\www\workspace\sydemas_ws_sei\target\classes, -verbose, -encoding, UTF-8, -extension, -wsdl, -r, C:\Development\www\workspace\sydemas_ws_sei\target\generated-sources\wsdl, com.xyzzy.sydemas.facade.SydemasFacadeImpl]
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
        ...few more lines here...

All the code is built with JDK 1.5, JAVA_HOME is set to the JDK 1.5. When I use 'javap' on the listed class file to see the version, it shows 49 which is the JDK 1.5 number.

The original POM used the old jaxws (version 1.10 from org.codehaus.mojo). I also tried the new one (2.3 from org.jvnet.jax-ws-commons) and it also fails.

I have searched all over and could not find a solution.

Thanks, Amir

1

There are 1 answers

1
herry On

This error occurs typically when you have .class that has been compiled with higher version of java than virtual machine trying to run it.

May be your maven use another version of jdk.

The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax.tools.JavaCompiler (if you are using java 1.6) and is used to compile Java sources. If you want to force the plugin using javac, you must configure the plugin option forceJavacCompilerUse.

Please check this link.