简体   繁体   中英

Apache CXF WSDL FileNotFoundException

This is the plugin command I am using to generate java code from a WSDL with maven and cxf's wsdl2java codegen plugin:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${basedir}/target/srcgen</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/main/resources/wsdl/ProjectService_1.0.wsdl</wsdl>
                        <serviceName>${ProjectService}</serviceName>
                        <extraargs>
                            <extraarg>-verbose</extraarg>
                            <extraarg>-autoNameResolution</extraarg>
                            <extraarg>-server</extraarg>
                            <extraarg>-impl</extraarg>
                            <extraarg>-p</extraarg>
                            <extraarg>com.company.project</extraarg>

                        </extraargs>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>

        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.8.1</version>
        </dependency>
    </dependencies>
</plugin>

This is the error I am getting:

Caused by: java.io.FileNotFoundException: /C:/workspace/wsdl2java/src/main/resources/wsdl/ProjectService_1.0.wsdl (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)

What am I doing wrong? Is it in the code generation command or do I need to do something with CXF to give it the WSDL?

Does the WSDL file exist at this location ?

<wsdl>${basedir}/src/main/resources/wsdl/ProjectService_1.0.wsdl</wsdl>

ie., C:/workspace/wsdl2java/src/main/resources/wsdl/ProjectService_1.0.wsdl

If not, copy the WSDL to this location or change the "<wsdl>" value to point to the WSDL file.

解决方案是编辑CXF bean文件中引用的Impl对象,并确保它没有WSDL的硬编码路径。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM