【问题标题】:JAX-WS Schema http://jax-ws.dev.java.net/spring/servlet.xsd not able to be found找不到 JAX-WS 架构 http://jax-ws.dev.java.net/spring/servlet.xsd
【发布时间】:2023-04-07 16:45:02
【问题描述】:

我正在使用 Spring 框架实现 JAX-WS。

以下是我的Spring applicationContext.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://jax-ws.dev.java.net/spring/core
    http://jax-ws.dev.java.net/spring/core.xsd
    http://jax-ws.dev.java.net/spring/servlet
    http://jax-ws.dev.java.net/spring/servlet.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    ">

但是,Eclipse 抱怨:

引用的文件包含错误 (http://jax-ws.dev.java.net/spring/servlet.xsd)。

经过调查,我找到了网址: http://jax-ws.dev.java.net/spring/servlet.xsd 不存在。 相反,它似乎要转移到: http://jax-ws.java.net/spring/servlet.xsd (您可以在浏览器中打开此链接)

因此,我从 http://jax-ws.dev.java.net/spring/servlet.xsdhttp://jax-ws.java.net/spring/servlet.xsd

现在我的 applicationContext.xml 看起来像这样:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://jax-ws.dev.java.net/spring/core
    http://jax-ws.java.net/spring/core.xsd
    http://jax-ws.dev.java.net/spring/servlet
    http://jax-ws.java.net/spring/servlet.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    ">

实际上,随着这种变化,Eclipse 错误消失了。 问题是在 Tomcat 7 中启动 Web 服务后,我收到以下运行时错误:

org.xml.sax.SAXParseException;行号:20;列号:29; schema_reference.4:未能读取架构文档'http://jax-ws.java.net/spring/servlet.xsd',因为 1) 找不到文档; 2) 文件无法读取; 3) 文档的根元素不是 . 在 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) 在 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:99) 在 com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:433)

请指教。

非常感谢。 问候,

【问题讨论】:

  • 您应该真正努力在生产应用程序中使用本地模式,否则您的应用程序将受制于这些不相关的第三方网络服务器。

标签: java web-services spring jax-ws


【解决方案1】:

您的问题是您将位置从http://jax-ws.dev.java.net/spring/servlet.xsd 更改为http://jax-ws.java.net/spring/servlet.xsd。尽管后一个是正确的 url,但它与 jaxws-spring.jar META-INF/spring.schema 文件中定义的内容不匹配。该文件应具有以下内容

http\://jax-ws.dev.java.net/spring/core.xsd=spring-jax-ws-core.xsd
http\://jax-ws.dev.java.net/spring/servlet.xsd=spring-jax-ws-servlet.xsd
http\://jax-ws.dev.java.net/spring/local-transport.xsd=spring-jax-ws-local-transport.xsd

Spring 使用此映射来搜索类路径中的架构而不是互联网。这些架构文件位于 jaxws-spring.jar 文件的根目录。

请看Registering the handler and the schema

【讨论】:

    【解决方案2】:

    你在你的项目中使用 spring 吗?我遇到了同样的问题,但是当我在我的 maven 依赖项中包含 spring-jaxws 时问题解决了,事实上,你可以在那个 jar 中看到 META-INF/spring. schemas 文件正在重新定义 XSD 位置

    【讨论】:

      【解决方案3】:

      资源已移动,最终配置应为:

      xsi:schemaLocation="http://www.springframework.org/schema/beans        
              http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
              http://www.springframework.org/schema/aop
              http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
              http://jax-ws.dev.java.net/spring/core 
              http://jax-ws.java.net/spring/core.xsd
              http://jax-ws.dev.java.net/spring/servlet 
              http://jax-ws.java.net/spring/servlet.xsd
              http://www.springframework.org/schema/tx 
              http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"
              default-lazy-init="true">
      

      【讨论】:

        【解决方案4】:

        可能不是你的情况。但是在这种情况下,请清理并重新构建。如果两个 jar 退出,原因是旧的 spring jar 和 xsd 从那里取出。希望对其他人有所帮助....一般而言,由于多种原因会引发此异常。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2011-02-25
          • 2011-03-19
          • 2012-01-11
          • 2011-07-19
          • 1970-01-01
          • 2011-10-20
          • 2019-01-10
          相关资源
          最近更新 更多