Maven cxf-codegen-plugin并在wsdl中导入

时间:2014-02-02 22:46:36

标签: java apache maven wsdl cxf

我正在尝试使用来自maven的apache cxf-codegen-plugin 从wsdl文件生成web服务类。 我的wsdl文件使用

导入xsd,如下所示
<xs:import namespace="http://my.ns.com/privateperson" schemaLocation="../xsd/PrivatePerson.xsd"/>

在pom.xml中我有:

<wsdlOption>
    <extraargs>
       <extraarg>-catalog ${basedir}/src/main/resources/xsd/PrivatePerson.xsd</extraarg>
       <extraarg>-server</extraarg>
    </extraargs>
    ...
</wsdlOptions>

然而,当我运行cxf-codegen-plugin时,我收到以下错误:

wsdl2java failed: org.apache.cxf.tools.common.toolspec.parser.BadUsageException: Unexpected option: -catalog valid/path/to/xsd/file/privateperson.xsd

我的配置有问题吗?当我不包含外部xsd文件时,一切正常。

我使用了目录,如下所述:http://cxf.apache.org/docs/wsdl-to-java.html

我也用-e:

运行maven
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.0.0-milestone1:wsdl2java (generate-sources) on project Services: unresolved reference -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.0.0-milestone1:wsdl2java (generate-sources) on project Services: unresolved reference
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.apache.maven.plugin.MojoExecutionException: unresolved reference
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:447)
at org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:311)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:524)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 25 more
Caused by: java.lang.InternalError: unresolved reference
at com.sun.xml.xsom.impl.parser.DelayedRef._get(DelayedRef.java:103)
at com.sun.xml.xsom.impl.parser.DelayedRef$Type.getType(DelayedRef.java:148)
at com.sun.xml.xsom.impl.ElementDecl.getType(ElementDecl.java:110)
at com.sun.xml.xsom.impl.ElementDecl.updateSubstitutabilityMap(ElementDecl.java:174)
at com.sun.xml.xsom.impl.parser.ParserContext.getResult(ParserContext.java:141)
at com.sun.xml.xsom.parser.XSOMParser.getResult(XSOMParser.java:211)
at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:538)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:269)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:95)
at org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:460)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:714)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:270)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:412)
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.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:427)
... 29 more

3 个答案:

答案 0 :(得分:1)

每个额外的论点都必须独立存在;你试图传递二合一,这是行不通的,因为插件为你正确引用的东西(或者将每个参数作为参数数组的单独元素传递,取决于它是否在封面下执行)或不)。

你想要这个:

<wsdlOption>
    <extraargs>
        <extraarg>-catalog</extraarg>
        <extraarg>${basedir}/src/main/resources/xsd/PrivatePerson.xsd</extraarg>
        <extraarg>-server</extraarg>
    </extraargs>
    ...
</wsdlOptions>

(请注意,正确获取目录可以进行实验; XML目录查找中的故障记录实际上是......几乎不存在。)

答案 1 :(得分:0)

尝试使用以下标记并检查其是否有效

 <wsdlOptions>
    <wsdlOption>
    <wsdl>${basedir}/<file-path></wsdl>
    </wsdlOption>
    </wsdlOptions>

还要检查您正在使用的cxf插件版本。尝试使用最新版本。

如果仍有错误,请告诉我

答案 2 :(得分:0)

好的,我已经解决了我的问题 - 在wsdl中我放了

<xs:import ... />

在错误的地方。它是在

之前
<wsdl:types>     

元素。