开发者

Hyperjaxb and Apache CXF

开发者 https://www.devze.com 2023-01-03 09:57 出处:网络
I\'m trying to use Hyperjaxb3 with Apache CXF to generate persistence annotations from a WSDL-first web service.I\'ve plugged the Hyperjaxb3-ejb-plugin into the cxf-codegen-plugin, like so.

I'm trying to use Hyperjaxb3 with Apache CXF to generate persistence annotations from a WSDL-first web service. I've plugged the Hyperjaxb3-ejb-plugin into the cxf-codegen-plugin, like so.

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>${cxf.version}</version>
  <dependencies>
    <dependency>
      <groupId>org.jvnet.jaxb2_commons</groupId>
      <artifactId>jaxb2-basics</artifactId>
      <version>0.5.2</version>
    </dependency>
    <dependency>    
      <groupId>org.jvnet.hyperjaxb3</groupId>
      <artifactId>hyperjaxb3-ejb-plugin</artifactId>
      <version>0.5.4</version>
    </dependency>
  </dependencies> 
  <executions>
    <execution>     
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <configuration>
        <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
        <wsdlOptions>
          <wsdlOption>
            <wsdl>${basedir}/src/main/resources/wsdl/CDXLEAToCourt.wsdl</wsdl>
            <xjcargs>
              <xjcarg>-Xequals</xjcarg>
              <xjcarg>-XtoString</xjcarg>
              <xjcarg>-Xhyperjaxb3-ejb</xjcarg>
            </xjcargs>
          </wsdlOption>
        </wsdlOptions>
      </configuration>
      <goals>
        <goal>wsdl2java</goal>
      </goals>
    </execution>
  </executions>
</plugin>

When I generate source, I get the following informative stack trace.

Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.2.7:wsdl2java (generate-sources) on project leaToCourtWS: Failed to generate types. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.2.7:wsdl2java (generate-sources) on project leaToCourtWS: Failed to generate types.
  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:585)
  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:597)
  at org.codehaus.plexus.classworlds.launche开发者_高级运维r.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)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to generate types.
  at org.apache.cxf.maven_plugin.WSDL2JavaMojo.callWsdl2Java(WSDL2JavaMojo.java:409)
  at org.apache.cxf.maven_plugin.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:361)
  at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
  ... 14 more
Caused by: org.apache.cxf.tools.common.ToolException: Failed to generate types.
  at org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.generate(JAXBDataBinding.java:716)
  at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:582)
  at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:228)
  at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:128)
  at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:271)
  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:406)
  ... 17 more

I've been banging my head against this for a while. I tried to continue the project without Hyperjaxb, but don't want to incur the maintenance costs. Any ideas? A solution to the exception- or an alternative to using Hyperjaxb- would be great.


Found a solution. I emailed Aleksei - the project owner- and he informed me that Hyperjaxb3 CXF integration was introduced in .5.5, which has yet to be released. D'oh!

He suggested I use the snapshot repository. I added the repository to my POM, changed the version of the hyperjaxb3-ejb-plugin to 0.5.5-SNAPSHOT- and so far, everything works beautifully.


It seems the problem comes from your WSDL file.

There is a working example within the source code of Hyperjaxb3 called customerservice-cxf that might help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号