解析 web-fragment.xml 失败 - 无法读取架构文档 'https://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd'
Failure parsing web-fragment.xml - Failed to read schema document 'https://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd'
我有一个由 maven 构建的 Spring Web 应用程序,它在 eclipse 环境中运行,但我试图将它部署到 tomcat 运行 Ubuntu服务器。
当我尝试将它部署到它抛出的服务器时:
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 中的任何位置找到这个文件。
相关软件ware版本:
- Tomcat 8.5
- Java 8
- Spring 5.1.7
有什么建议吗?
编辑**
当 xsd 文件 url 是 https 时似乎会发生故障,但当常规 http
时则不会
我们运行遇到了同样的问题。
这实际上不是 ssl 问题(根本没有 ssl 日志),而是 http 中的命名空间与 https 中的架构位置之间似乎不一致。
一个可能的解决方案是在不需要时禁用此验证。
将以下参数添加到您的 jvm.properties :
-Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false
可能这个 属性 已经定义了一个 true
值,这会导致验证。
如果您想确切了解 属性 的功能,可以在 the official Tomcat 8 configuration manual
查看
希望它能解决您的问题。
@TheCopycat's work-around seems good — just to add that the cause appears to be a buggy change in spring-web 5.1.6, as reported in Spring Framework issue #23592.
我仍然注意到这个问题在我的 tomcat 服务器 apache-tomcat-8.5.66 上仍然存在。虽然@TheCopycat 的回答工作得很好,但我注意到禁用 STRICT_SERVLET_COMPLIANCE 可能会更改其他依赖属性的默认值以及 Tomcat changes here.
中提到的
对我来说,在 context.xml 中禁用 xmlValidation 属性,在这个 segment 中解释,同样有效。
我有一个由 maven 构建的 Spring Web 应用程序,它在 eclipse 环境中运行,但我试图将它部署到 tomcat 运行 Ubuntu服务器。
当我尝试将它部署到它抛出的服务器时:
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 中的任何位置找到这个文件。
相关软件ware版本:
- Tomcat 8.5
- Java 8
- Spring 5.1.7
有什么建议吗?
编辑**
当 xsd 文件 url 是 https 时似乎会发生故障,但当常规 http
时则不会我们运行遇到了同样的问题。
这实际上不是 ssl 问题(根本没有 ssl 日志),而是 http 中的命名空间与 https 中的架构位置之间似乎不一致。
一个可能的解决方案是在不需要时禁用此验证。 将以下参数添加到您的 jvm.properties :
-Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false
可能这个 属性 已经定义了一个 true
值,这会导致验证。
如果您想确切了解 属性 的功能,可以在 the official Tomcat 8 configuration manual
查看希望它能解决您的问题。
@TheCopycat's work-around seems good — just to add that the cause appears to be a buggy change in spring-web 5.1.6, as reported in Spring Framework issue #23592.
我仍然注意到这个问题在我的 tomcat 服务器 apache-tomcat-8.5.66 上仍然存在。虽然@TheCopycat 的回答工作得很好,但我注意到禁用 STRICT_SERVLET_COMPLIANCE 可能会更改其他依赖属性的默认值以及 Tomcat changes here.
中提到的对我来说,在 context.xml 中禁用 xmlValidation 属性,在这个 segment 中解释,同样有效。