Problems with my Apache CXF client

2019-06-16 03:31发布

问题:

I'm trying to write an Apache CXF JAX-WS client.

The dependencies in my pom.xml are

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-common-utilities</artifactId>
    <version>${cxf.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-tools-common</artifactId>
    <version>${cxf.version}</version>
</dependency>

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>${cxf.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>${cxf.version}</version>
</dependency>

where:

<cxf.version>2.4.0</cxf.version>

Unfortunately, when uses Maven uses the code generator (org.apache.cxf:cxf-codegen-plugin:${cxf.version}), it barfs:

[DEBUG] Calling wsdl2java with args: [-d, C:\projects\src\b2b_pmd\trunk\b2b_pmd\pmd-service\promotionalDocument\target\generated\src\main\java, -client, -verbose, file:/C:/projects/src/b2b_pmd/trunk/b2b_pmd/pmd-service/promotionalDocument/src/main/wsdl/test.wsdl]
Loading FrontEnd jaxws ...
Loading DataBinding jaxb ...
wsdl2java -d C:\projects\src\b2b_pmd\trunk\b2b_pmd\pmd-service\promotionalDocument\target\generated\src\main\java -client -verbose file:/C:/projects/src/b2b_pmd/trunk/b2b_pmd/pmd-service/promotionalDocument/src/main/wsdl/test.wsdl
wsdl2java - Apache CXF 2.4.0

[DEBUG] 
java.lang.AbstractMethodError: org.apache.xerces.dom.ElementNSImpl.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;
    at org.apache.cxf.staxutils.StaxUtils.addLocation(StaxUtils.java:1085)
    at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:973)
    at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:949)
    at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:876)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:226)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:186)
    at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:78)
    at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.build(WSDLDefinitionBuilder.java:69)
    at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:84)
    at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:61)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:171)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:138)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:290)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
    at org.apache.cxf.maven_plugin.WSDL2JavaMojo.callWsdl2Java(WSDL2JavaMojo.java:586)
    at org.apache.cxf.maven_plugin.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:412)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeForkedExecutions(DefaultLifecycleExecutor.java:685)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:560)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

Is there something I'm missing?

回答1:

You have an ancient version of xerces in your classpath someplace as well. Do a mvn dependency:tree and see if there are any xerces related jars that need to be removed.



回答2:

i also had similiar problem but adding below to pom fix my issue as well..

groupId: xerces ,artifactId : xercesImpl, version>2.9.1