Ant WsImport2 Fails With java.lang.NoClassDefFoundError:

Ant WsImport2 Fails With java.lang.NoClassDefFoundError:

我已经这样定义了我的 Ant 脚本:

<taskdef name="xjc" classname="com.sun.tools.xjc.XJC2Task">
    <classpath>
        <path refid="extraJars" />
    </classpath> 
</taskdef>

<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport2">
    <classpath>
        <path refid="extraJars" />
    </classpath>
</taskdef>

在 "extraJars" 中,我拥有完成 运行 任务所需的所有 Jar。喜欢:

jaxb-api-2.3.1.jar
jaxb-impl-2.2.6.jar
jaxb-xjc-2.2.7.jar
jaxws-tools-2.3.2.jar

现在,当我 运行 脚本时,出现错误:

H:\Workspace\common-build.xml:740: java.lang.NoClassDefFoundError: com/sun/istack/localization/LocalizableMessageFactory$ResourceBundleSupplier
        at com.sun.tools.ws.wscompile.WsimportToolAuthListener.onError(WsimportTool.java:377)
        at com.sun.istack.tools.DefaultAuthenticator.setAuth(DefaultAuthenticator.java:138)
        at com.sun.tools.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:400)
        at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:175)
        at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:153)
        at com.sun.tools.ws.ant.WsImportBase.runInVm(WsImportBase.java:569)
        at com.sun.tools.ws.ant.WsTask2.execute(WsTask2.java:457)
        at com.sun.tools.ws.ant.WsImportBase.execute(WsImportBase.java:552)
        at com.sun.tools.ws.ant.WsImport2.execute(WsImport2.java:23)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
        at org.apache.tools.ant.Task.perform(Task.java:350)
        at org.apache.tools.ant.Target.execute(Target.java:449)
        at org.apache.tools.ant.Target.performTasks(Target.java:470)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
        at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:437)
        at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:306)
        at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:225)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
        at org.apache.tools.ant.Task.perform(Task.java:350)
        at org.apache.tools.ant.Target.execute(Target.java:449)
        at org.apache.tools.ant.Target.performTasks(Target.java:470)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        at org.apache.tools.ant.Main.runBuild(Main.java:834)
        at org.apache.tools.ant.Main.startAnt(Main.java:223)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
Caused by: java.lang.ClassNotFoundException: com.sun.istack.localization.LocalizableMessageFactory$ResourceBundleSupplier
        at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1362)
        at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1313)
        at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1068)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 39 more

Total time: 11 seconds

我做了一些 google,我看到我包含的 class com/sun/istack/localization/LocalizableMessageFactory$ResourceBundleSupplier 存在 jaxb-Impl jar。我检查了 Java2s 网站。你能告诉我它哪里出错了吗,或者我需要一些额外的 JARS 吗?

只是想补充一点,构建文件中的第 740 行是:

 <wsimport wsdl="${build.dir}/src/${wsdl.file}" destdir="build" wsdlLocation="file:/WEB-INF/wsdl/${wsdl.file}" failonerror="true">
        <depends dir="${build.dir}/src" includes="*.xsd" /> 
        <produces dir="${lib.dir}" includes="${webservice.name}${webservice.component}WSBeans.jar"/>
    </wsimport>

我用 JAXB Core Jar 的更新版本修复了它。

失踪的 class 在:

jaxb-core-2.3.0.1.jar

之前,我使用的是:

jaxb-core-2.2.7.jar