'Failure parsing web-fragment.xml - Failed to read schema document 'https://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd'
I have a Spring web application built by maven that runs in an eclipse environment, but I am trying to deploy it to tomcat running on an Ubuntu server.
When I try to deploy it to the server it throws:
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>.
I have confirmed that I can download a proper xsd file from this url from the server, but the error persists. I know that many of the spring xsd files are located in their jars, but I cannot locate this one anywhere in the generated war or spring jar.
Relevant software versions:
- Tomcat 8.5
- Java 8
- Spring 5.1.7
Any suggestions?
EDIT**
Failure appears to happen when xsd file url is https but not when regular http
Solution 1:[1]
We ran into the same problem.
This was actually not a ssl issue (there were no ssl logs at all), but rather seemed an incoherence between the namespace in http and the schema location in https.
One possible solution is to disable this validation if it is not required. Add the following parameter to your jvm.properties :
-Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false
Chances are that this property is already defined with a true value, which causes the validation.
If you want to know exactly what the property does, you can review at the official Tomcat 8 configuration manual
Hope it solves your problem.
Solution 2:[2]
@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.
Solution 3:[3]
I have still noted this issue persist for me on my tomcat server apache-tomcat-8.5.66. While @TheCopycat's answer works just fine, i have noticed that disabling STRICT_SERVLET_COMPLIANCE could change the default values for other dependent properties as well as mentioned in the Tomcat changes here.
For me just disabling the xmlValidation property in context.xml, explained in this segment, works equally fine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TheCopycat |
| Solution 2 | LarryW |
| Solution 3 | Leo |
