vaugham
vaugham

Reputation: 1851

SAXParseException, the root element of the document is not <xsd:schema>

Here is the header of my spring-security.xml :

<?xml version="1.0" encoding="UTF-8" ?>
<b:beans xmlns:b="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:sec="http://www.springframework.org/schema/security"
         xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
         xmlns:context="http://www.springframework.org/schema/context"  
         xmlns:mvc="http://www.springframework.org/schema/mvc"  

         xsi:schemaLocation="http://www.springframework.org/schema/security
          http://www.springframework.org/schema/security/spring-security-3.2.xsd
          http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
          http://www.springframework.org/schema/security/oauth2
          http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.2.xsd
          http://www.springframework.org/schema/mvc
          http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd  ">

When starting the server, I am prompted this error :

org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/security/spring-security-oauth2-2.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/>.

My thoughts on this :

  1. The link is valid and the document exists

  2. I can read it and I can even reproduce this error if I place this xsd on my local classpath. So it's not a networking issue.

  3. That's right, the file is starting by <xs:schema> instead of <xsd:schema>. But the source looks legit.

Why do I get this error and how can I get rid of it ?

Upvotes: 0

Views: 9178

Answers (1)

Brian Clozel
Brian Clozel

Reputation: 59056

Change all your schema locations to use version-less URIs, those XSDs are embedded in Spring JARs.

Because you're using versioned links to XSDs, your application breaks if it can't find that particular version on classpath.

See this SO answer for more details.

Upvotes: 3

Related Questions