开发者

cxf-codegen-plugin keeps giving me "Failed to generate types" error message

Hoping for some feedback on this issue that has been troubling for a while.

I use maven for building a simple web services client application.

It uses several wsdls ( around 8 ) the wsdls have xsd imports ( roughly 2 per wsdl for each request and response, plus a good amount of additional imports ) to generate the java code using a maven cxf wsdl2java plugin.

I started with the plugin version 2.1.7 tried several 2.2.x and now trying with version 2.3.4 of the plugin.

Here is the plugin section of my pom file:

        <plugin>
              <groupId>org.apache.cxf</groupId>
              <artifactId>cxf-codegen-plugin</artifactId>
              <version>2.3.4</version>
              <executions>
                 <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <defaultOptions>
                            <noAddressBinding>true</noAddressBinding>
                        </defaultOptions>
                        <wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot>
                        <includes>
                              <include>*.wsdl</include>
                         </includes>
                    </configuration>
                    <goals>
                       <goal>wsdl2java</goal>
                    </goals>
                 </execution>
              </executions> 
          </plugin>
      </plugins>

I can provide a previous version of how this used to work for me in the past. Basically I had each individual wsdl listed as a < wsdloption > item.

The only thing that I did "environment" related was that for a separate project I deleted everything in my m2 folder. Since then doing the code generation gives me the following error message( using "mvn -e generate-sources" from the command ):

    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] Failed to generate types.

    [INFO] ------------------------------------------------------------------------
    [INFO] Trace
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to generate types.
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:584)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:500)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:479)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:331)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:292)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:301)
            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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
            at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
            at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
            at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
    Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to generate types.
            at org.apache.cxf.maven_plugin.WSDL2JavaMojo.callWsdl2Java(WSDL2JavaMojo.java:413)
            at org.apache.cxf.maven_plugin.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:362)
            at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:453)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
            ... 16 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:745)
            at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:599)
            at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:247)
            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:410)
            ... 19 more

One thing that I've noticed is that in the target/generated-sources f开发者_开发问答older it creates the same classes in the \generated-sources\cxf\generated AND \generated-sources\org\opentravel\ota_2003_05. Not exactly sure if there is an error in the XSDs or the wsdl themselves.

I have looked for a good explanation of the error and haven't found a solution yet. I have done my fair share of "googling" for this particular issue. Starting to get desperate and hope I can find a solution soon.

Thanks in advance for any help you can provide.


I see this from time to time, when I am using the cxf java plugin, I think the cxf.maven.wsdl2javaMojo run out of memory.

in this case,

  • I would recommend you to break the each wsdl generation into sub-modules,
  • increase the maven memory
  • if it still stops at the middle try to using the mvn Goals -rf :WhereStops command, so it starts at the sub-module which run out memory, thus you don't have to start all over again.

Note I use Maven 3.2 if you not sure how -rf works google mvn -rf


Not really sure. I just looked at the code at that line number and, unfortunately, just discovered that it's completely swallowing an IOException at that point. Thus, I have no idea how to get the real "cause" of that IOException. I'm going to fix that and get it committed to trunk. If you could retry with the latest snapshots tomorrow or monday (after the nightly deploy builds), it should likely provide a much better/complete error message.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜