Spring Custome schema Loading Error: White spaces are required between publicId and systemId.

Spring project startup error

The error log is as follows:

Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from URL [jar:file:webapps/ROOT/WEB-INF/lib/xxx-biz-1.0.jar!/xxx/sponsor-group-pipeline.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://www.xxx.com/schema/hipac/pipeline.xsd; lineNumber: 1; columnNumber: 50; White spaces are required between publicId and systemId.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399) ~[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) ~[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) ~[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:245) ~[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
    ... 54 common frames omitted
Caused by: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) ~[na:1.8.0_45]

Google has been saying for a long time that there should be a space between systemid and PublicID defined by XML header, which is the content of this lump

<?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:hipac="http://www.xxx.com/schema/hipac"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.xxx.com/schema/hipac http://www.xxx.com/schema/hipac/pipeline.xsd"&>

It’s the red part above. You can see that there is no problem with my configuration

What’s the problem?At the beginning, I always suspected the jar package conflict, but after a long time of investigation, compared with many jar versions of other normal applications, no problem was found

Since this scheme is defined by myself, there is a corresponding configuration resolution in spring, that is spring.handlers and spring.schemas Two documents. Let’s look at the contents of these two documents





One of these two files specifies the path of XSD, and the other is the parsing class of schemas. It is suspected that there is a problem with the loading of these two files

So I searched these two files in the access application code, and found that there are actually these two configuration files in the application, and the contents are similar (only the values are different, and the corresponding class and XSD can’t be found in the code). I’m very suspicious here, and the probability is the problem.

Next, delete these two files immediately and deploy them again. OK, it’s successful.

After this problem, let me remember that another application had this situation when it was just connected, but I forgot how to solve it at that time. In retrospect, it was actually caused by the wrong class path or XSD path in the configuration file at that time.

However, the prompt for spring startup is also a pitfall. It’s too misleading. I always think it’s a problem with the referenced configuration file, which wastes a lot of time. I’ll take a good look at spring’s parsing of sechemas later.

Similar Posts: