为什么 CXF WSDLToJava 的 Ant/Ivy 集成不起作用?

发布于 2024-10-20 18:07:34 字数 2746 浏览 0 评论 0 原文

我想在我的 Apache CXFWSDLToJava ://ant.apache.org/" rel="nofollow">Ant 构建文件,用于从 WSDL 创建 Java 代码。使用 Ivy 解决依赖关系。我总是收到以下错误:

WSDLToJava Error: Could not find jaxb databinding within classpath

我没有安装,想使用 Ivy 来帮我完成这项工作。这是我的 Ant 构建文件的一部分:

<target name="generate" depends="init">
  <ivy:retrieve conf="build"/>
  <mkdir dir="${basedir}/target/generated"/>
  <ivy:cachepath pathid="build-classpath" conf="build"/>
  <java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
    <arg value="-d"/>
    <arg value="${basedir}/target/generated"/>
    <arg value="-client"/>
    <arg value="${basedir}/src/schema/MyWebService.wsdl"/>
    <classpath refid="build-classpath"/>
  </java>
</target>

我使用 Java 6、Ant 1.8、Ivy 2.2.0 ant CXF 2.2.12。在ivy模块中我配置了以下内容:

<configurations>
  <conf name="build" visibility="private"/>
  ...
</configurations>

<dependencies defaultconfmapping="*->default">
  <dependency org="org.apache.cxf" name="cxf-tools-wsdlto-frontend-jaxws" rev="2.2.12" conf="build"/>
  <dependency org="org.apache.cxf" name="cxf-rt-databinding-jaxb" rev="2.2.12" conf="build"/>
  ...
</dependencies>

问题出在哪里?也许缺少一个依赖项,但是是哪一个呢?如果没有 Ivy,Ant 集成将使用包含 CXF 安装的所有 jar 的类路径。如果我这样做,它就会起作用。

在构建的输出中我看到以下内容:

generate (2s)
[generate] ivy:retrieve (1s)
[ivy:retrieve] :: resolving dependencies :: me#mine;1.0
[ivy:retrieve] confs: [build]
[ivy:retrieve] found org.apache.cxf#cxf-tools-wsdlto-frontend-jaxws;2.2.12 in public
[ivy:retrieve] found org.apache.cxf#cxf-tools-common;2.2.12 in public
[ivy:retrieve] found oro#oro;2.0.8 in public
[ivy:retrieve] found wsdl4j#wsdl4j;1.6.2 in public
[ivy:retrieve] found com.sun.xml.bind#jaxb-xjc;2.1.13 in public
[ivy:retrieve] found com.sun.xml.bind#jaxb-impl;2.1.13 in public
[ivy:retrieve] found javax.xml.bind#jaxb-api;2.1 in public
[ivy:retrieve] found javax.xml.stream#stax-api;1.0-2 in public
[ivy:retrieve] found javax.xml.soap#saaj-api;1.3 in public
[ivy:retrieve] found org.apache.cxf#cxf-api;2.2.12 in public
[ivy:retrieve] found org.apache.cxf#cxf-common-utilities;2.2.12 in public
... (many more) 
[ivy:retrieve] :: retrieving :: me#mine
[ivy:retrieve] confs: [build]
[ivy:retrieve] 32 artifacts copied, 28 already retrieved (8959kB/38ms)
[generate] mkdir
[mkdir] Created dir: /tmp/target/generated
[generate] java (1s)
[java] WSDLToJava Error: Could not find jaxb databinding within classpath

I would like to use WSDLToJava of Apache CXF in my Ant buildfile to create Java code from a WSDL. The dependencies are resolved using Ivy. I always get the following error:

WSDLToJava Error: Could not find jaxb databinding within classpath

I do not have an installation and want to use Ivy to do the job for me. Here is the part of my Ant buildfile:

<target name="generate" depends="init">
  <ivy:retrieve conf="build"/>
  <mkdir dir="${basedir}/target/generated"/>
  <ivy:cachepath pathid="build-classpath" conf="build"/>
  <java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
    <arg value="-d"/>
    <arg value="${basedir}/target/generated"/>
    <arg value="-client"/>
    <arg value="${basedir}/src/schema/MyWebService.wsdl"/>
    <classpath refid="build-classpath"/>
  </java>
</target>

I use Java 6, Ant 1.8, Ivy 2.2.0 ant CXF 2.2.12. In the Ivy module I configured the following:

<configurations>
  <conf name="build" visibility="private"/>
  ...
</configurations>

<dependencies defaultconfmapping="*->default">
  <dependency org="org.apache.cxf" name="cxf-tools-wsdlto-frontend-jaxws" rev="2.2.12" conf="build"/>
  <dependency org="org.apache.cxf" name="cxf-rt-databinding-jaxb" rev="2.2.12" conf="build"/>
  ...
</dependencies>

Where is the problem? Maybe there is a dependency missing, but which one? Without Ivy, the Ant integration uses a classpath with all jars of the CXF installation. If I do so, it works.

In the output of the build I see the following:

generate (2s)
[generate] ivy:retrieve (1s)
[ivy:retrieve] :: resolving dependencies :: me#mine;1.0
[ivy:retrieve] confs: [build]
[ivy:retrieve] found org.apache.cxf#cxf-tools-wsdlto-frontend-jaxws;2.2.12 in public
[ivy:retrieve] found org.apache.cxf#cxf-tools-common;2.2.12 in public
[ivy:retrieve] found oro#oro;2.0.8 in public
[ivy:retrieve] found wsdl4j#wsdl4j;1.6.2 in public
[ivy:retrieve] found com.sun.xml.bind#jaxb-xjc;2.1.13 in public
[ivy:retrieve] found com.sun.xml.bind#jaxb-impl;2.1.13 in public
[ivy:retrieve] found javax.xml.bind#jaxb-api;2.1 in public
[ivy:retrieve] found javax.xml.stream#stax-api;1.0-2 in public
[ivy:retrieve] found javax.xml.soap#saaj-api;1.3 in public
[ivy:retrieve] found org.apache.cxf#cxf-api;2.2.12 in public
[ivy:retrieve] found org.apache.cxf#cxf-common-utilities;2.2.12 in public
... (many more) 
[ivy:retrieve] :: retrieving :: me#mine
[ivy:retrieve] confs: [build]
[ivy:retrieve] 32 artifacts copied, 28 already retrieved (8959kB/38ms)
[generate] mkdir
[mkdir] Created dir: /tmp/target/generated
[generate] java (1s)
[java] WSDLToJava Error: Could not find jaxb databinding within classpath

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三人与歌 2024-10-27 18:07:34

您可能还需要一个 cxf-tools-wsdlto-databinding-jaxb 依赖项。由于多种原因,JAXB 的工具和运行时是分开的。

There is a cxf-tools-wsdlto-databinding-jaxb dependency that you likely need as well. For a variety of reasons, the tooling and runtime are separate for JAXB.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文