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"中,我拥有运行任务所需的所有Jars。喜欢:

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:Workspacecommon-build.xml:740: java.lang.NoClassDefFoundError: com/sun/istack/localization/LocalizableMessageFactory$ResourceBundleSupplier
        at com.sun.tools.ws.wscompile.WsimportTool$1AuthListener.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

做了一些谷歌,我看到类com/sun/istack/localization/LocalizableMessageFactory$ResourceBundleSupplier是我包含的jaxb-Impl罐子。我检查了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的更新版本修复了它。

缺少的类在:

jaxb-core-2.3.0.1.jar

以前,我使用:

jaxb-core-2.2.7.jar

相关内容

  • 没有找到相关文章

最新更新