2014-01-06 46 views
0

我想編譯一個使用JDK 1.5.0_13和Maven 2.2.1的舊項目。Maven jaxws插件無法通過java.lang.UnsupportedClassVersionError:.class文件中的版本號不正確

在 'JAXWS-行家-插件' 失敗,此消息:

[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... 

所有代碼是建立與JDK 1.5,JAVA_HOME被設置爲JDK 1.5。 當我在列出的類文件上使用'javap'來查看版本時,它顯示49是JDK 1.5編號。

最初的POM使用舊的jaxws(版本1.10 org.codehaus.mojo)。我也嘗試了新的(來自org.jvnet.jax-ws-commons的2.3),它也失敗了。

我已經遍尋搜索並找不到解決方案。當你有一個已經編有更高版本的Java虛擬比機器試圖運行它的.class

謝謝,阿米爾

回答

0

這個錯誤通常發生。

可能是你的maven使用另一個版本的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.

請檢查this link.

+0

謝謝,但它並沒有解決問題。我懷疑Maven的內置「wsgen」是問題所在。現在,我註釋了項目中jaxws插件的調用,並設法在沒有WSDL文件的情況下構建項目。我可能會在未來重新訪問這個問題。 –

相關問題