首页 > 解决方案 > 尝试定位 WSL 时出现 JBoss EAP 7.3 错误

问题描述

我正在尝试部署一个基本的 Web 服务,我的 wsdl 位于如下 beans.xml 中所示:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:jaxws="http://cxf.apache.org/jaxws"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

        <import resource="classpath:META-INF/cxf/cxf.xml" />

        <jaxws:endpoint 
          id="helloWorld" 
          implementor="com.tsdevelopment.HelloWorldImpl" 
      wsdlLocation="src/main/resources/wsdl/HelloWorld.wsdl"
          address="/HelloWorld" />
          
</beans>

当我使用 mvn wildfly:deploy 部署时,出现以下错误:

Caused by: java.io.FileNotFoundException: C:\Users\codereadystudio\jboss-eap-7.3\bin\src\main\resources\wsdl\HelloWorld.wsdl (The system cannot find the path specified)
    at java.base/java.io.FileInputStream.open0(Native Method)
    at java.base/java.io.FileInputStream.open(FileInputStream.java:211)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:153)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:108)
    at java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86)
    at java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:189)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:1009)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:144)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:832)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:798)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:230)
    at org.apache.xerces@2.12.0.SP02-redhat-00001//org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:298)
    at deployment.soap-cxf-wsdlfirst-jbosseap73-1.0-SNAPSHOT.war//com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2188)
    ... 56 more

为什么它在 jboss 安装文件夹而不是代码中搜索 WSDL?

标签: web-servicesjboss

解决方案


似乎无法找到 WSDL 的原因是,在 pom.xml 中,wsdl 路径如下:

<wsdlOptions>
  <wsdlOption>
    <wsdl>
      src/main/resources/wsdl/HelloWorld.wsdl
    </wsdl>                                      
    <wsdlLocation>wsdl/HelloWorld.wsdl</wsdlLocation>
  </wsdlOption>
</wsdlOptions>

cxf cxf-codegen-plugin 生成的java类没有在@WebService注解中包含wsdlLocation参数。另请注意,参数路径必须仅包含构建路径下的文件夹。也就是说,虽然我的 pom.xml 位置是 /src/main/resources/wsdl/HelloWorld.wsdl,但我的参数是 wsdl/HelloWorld.wsdl,因为我已经在构建路径中包含了 /src/main/resources 文件夹。


推荐阅读