我想在Apache CXF构建文件中使用WSDLToJava
WSDLToJava Error: Could not find jaxb databinding within classpath
来从WSDL创建Java代码。使用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>
我没有安装,想让Ivy为我做这份工作。这是我的Ant构建文件的一部分:
<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>
我使用Java 6,Ant 1.8,Ivy 2.2.0 ant CXF 2.2.12。在常春藤模块中,我配置了以下内容:
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
问题出在哪里?也许有一个依赖缺失,但哪一个?如果没有Ivy,Ant集成将使用包含CXF安装的所有jar的类路径。如果我这样做,它就有效。
在构建的输出中,我看到以下内容:
{{1}}
答案 0 :(得分:8)
您可能还需要cxf-tools-wsdlto-databinding-jaxb
依赖项。出于各种原因,工具和运行时对于JAXB是独立的。