【问题标题】:Failure parsing web-fragment.xml - Failed to read schema document 'https://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd'解析 web-fragment.xml 失败 - 无法读取架构文档“https://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd”
【发布时间】:2019-06-18 22:22:45
【问题描述】:

我有一个在 Eclipse 环境中运行的由 maven 构建的 Spring Web 应用程序,但我正在尝试将它部署到在 Ubuntu 服务器上运行的 tomcat。

当我尝试将它部署到它抛出的服务器时:

org.xml.sax.SAXParseException; systemId: 
jar:file:/usr/share/tomcat8.5/webapplications/OpenElis2/WEB-INF/lib/spring-web-5.1.7.RELEASE.jar!/META-INF/web-fragment.xml;
lineNumber: 8; columnNumber: 18; schema_reference.4: 
Failed to read schema document 
'https://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd', 
because 
    1) could not find the document; 
    2) the document could not be read; 
    3) the root element of the document is not <xsd:schema>.

我已确认我可以从服务器的该 url 下载正确的 xsd 文件,但错误仍然存​​在。我知道许多 spring xsd 文件都位于它们的 jar 中,但我无法在生成的 war 或 spring jar 中的任何位置找到这个文件。

相关软件版本:

  • Tomcat 8.5
  • Java 8
  • 春天 5.1.7

有什么建议吗?

编辑**

xsd 文件 url 为 https 时似乎会发生故障,但在常规 http 时不会发生

【问题讨论】:

    标签: xml maven tomcat xsd


    【解决方案1】:

    我们遇到了同样的问题。

    这实际上不是 ssl 问题(根本没有 ssl 日志),而是 http 中的命名空间与 https 中的架构位置之间似乎不一致。

    如果不需要,一个可能的解决方案是禁用此验证。 将以下参数添加到您的 jvm.properties:

    -Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false
    

    很可能该属性已使用true 值定义,这会导致验证。

    如果您想确切了解该物业的用途,可以查看the official Tomcat 8 configuration manual

    希望它能解决你的问题。

    【讨论】:

    • 这解决了问题!我们在 tomcat 的 conf/catalina.properties 文件中设置了 STRICT_SERVLET_COMPLIANCE=false。
    【解决方案2】:

    @TheCopycat 的解决方法似乎不错——只是补充一下,原因似乎是 spring-web 5.1.6 中的错误更改,正如 Spring Framework issue #23592 中所报告的那样。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-04
      相关资源
      最近更新 更多