cxf maven java2wsdl插件错误生成wsdl

时间:2015-11-06 11:00:57

标签: java web-services maven wsdl cxf

我正在尝试使用Apache CXF和Maven生成WS,当我尝试使用cxf-java2wsdl maven插件从java类生成wsdl时,我收到此错误

[ERROR] Failed to execute goal org.apache.cxf:cxf-java2ws-   plugin:3.0.6:java2ws (process-classes) on project mdsWS:      org.apache.cxf.tools.java2ws.JavaToWSContainer could not be constructed: Fail to parse toolspec file: Cannot create a secure XMLInputFactory -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-java2ws-plugin:3.0.6:java2ws (process-classes) on project mdsWS: org.apache.cxf.tools.java2ws.JavaToWSContainer could not be constructed
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:203)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
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:314)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:132)
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.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)
Caused by: org.apache.maven.plugin.MojoExecutionException: org.apache.cxf.tools.java2ws.JavaToWSContainer could not be constructed
at org.apache.cxf.maven_plugin.Java2WSMojo.processJavaClass(Java2WSMojo.java:374)
at org.apache.cxf.maven_plugin.Java2WSMojo.execute(Java2WSMojo.java:231)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
... 19 more
Caused by: org.apache.cxf.tools.common.ToolException: org.apache.cxf.tools.java2ws.JavaToWSContainer could not be constructed
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:93)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:58)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:40)
at org.apache.cxf.tools.java2ws.JavaToWS.run(JavaToWS.java:77)
at org.apache.cxf.maven_plugin.Java2WSMojo.processJavaClass(Java2WSMojo.java:363)
... 22 more
Caused by: org.apache.cxf.tools.common.ToolException: Fail to parse toolspec file
at org.apache.cxf.tools.common.toolspec.ToolSpec.<init>(ToolSpec.java:76)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:86)
... 26 more
Caused by: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
at org.apache.cxf.staxutils.StaxUtils.createXMLInputFactory(StaxUtils.java:323)
at org.apache.cxf.staxutils.StaxUtils.getXMLInputFactory(StaxUtils.java:273)
at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1723)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1119)
at org.apache.cxf.tools.common.dom.ExtendedDocumentBuilder.parse(ExtendedDocumentBuilder.java:100)
at org.apache.cxf.tools.common.toolspec.ToolSpec.<init>(ToolSpec.java:73)
... 27 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

我的pom.xml是这样的:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mdsService</groupId>
<artifactId>mdsWS</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>mdsService</name>
<description>mdsService</description>

<properties>
    <cxf.version>3.0.6</cxf.version>
</properties>

<dependencies>
    <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>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.6</version>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-java2ws-plugin</artifactId>
            <version>${cxf.version}</version>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.woodstox</groupId>
                    <artifactId>woodstox-core-asl</artifactId>
                    <version>4.2.1</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-core</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-frontend-simple</artifactId>
                    <version>${cxf.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>process-classes</id>
                    <phase>process-classes</phase>
                    <configuration>
                        <className>com.mdef.cgea.sl2k.mds.service.MdsServicer</className>
                        <genWsdl>true</genWsdl>
                        <verbose>true</verbose>
                        <outputFile>${project.build.directory}/generated/wsdl/${className}.wsdl</outputFile>
                        <genServer>false</genServer>
                        <genClient>false</genClient>
                        <genWrapperbean>true</genWrapperbean>
                        <frontend>jaxws</frontend>
                        <databinding>jaxb</databinding>
                        <serviceName>serviceMDS</serviceName>
                        <soap12>true</soap12>
                        <targetNameSpace>http://service.mds.sl2k.cgea.mdef.com/</targetNameSpace>
                        <quiet>false</quiet>
                        <attachWsdl>true</attachWsdl>
                    </configuration>
                    <goals>
                        <goal>java2ws</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

如何解决这个问题?

THX

编辑:当我尝试通过cxf eclipse插件生成wsdl时,它可以工作,但是为了开发可维护的代码,重要的maven集成来生成wsdl

0 个答案:

没有答案