Failed to read schema document of spring.security

11,344

Your xml file should start with something like this:

<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd">

and the .xsd schemas are in spring-security-config jar.

Share:
11,344
DarkCoffee
Author by

DarkCoffee

Updated on June 06, 2022

Comments

  • DarkCoffee
    DarkCoffee almost 2 years

    My spring-security.xml is

    <beans:beans xmlns="http://www.springframework.org/schema/security"
        xmlns:beans="http://www.springframework.org/schema/beans" 
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-3.2.xsd"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
    
    <http auto-config="true">
        <intercept-url pattern="/admin**" access="ROLE_USER" />
    </http>
    
    <authentication-manager>
      <authentication-provider>
        <user-service>
        <user name="admin" password="admin" authorities="ROLE_USER" />
        </user-service>
      </authentication-provider>
    </authentication-manager>
    

    When I start the server (Tomcat 7) inside Eclipse I get this error:

    Ignored XML validation warning org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/security/spring-security-3.2.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .

    The libraries I've imported are:

    commons-logging

    • jsp
    • jstl
    • spring-aop-4.0.4
    • spring-beans-4.0.4
    • spring-context-4.0.4
    • spring-core-4.0.4
    • spring-expression-4.0.4
    • sprig-web-4.0.4
    • spring-webmvc-4.0.4
    • spring-security-core-3.2.4

    I believe there are some problems with the library version, but I'm not sure. I tried to search the version 4.0.4 but I haven't found it.

    Is the spring-security library included in another one? If yes, where can I look into when I need to know the unifications between the spring versions?

    How can I solve the error?

    I googled all my questions but I haven't found anything.

  • DarkCoffee
    DarkCoffee almost 10 years
    Thank you for the answer. It is like this. I added the security-config jar and I got this error: 'GRAVE: Context initialization failed org.springframework.beans.factory.parsing.BeanDefinitionPars‌​ingException: Configuration problem: The classes from the spring-security-web jar (or one of its dependencies) are not available. You need these to use <http> Offending resource: ServletContext resource [/WEB-INF/spring-security.xml]:'
  • Andrei Stefan
    Andrei Stefan almost 10 years
    Well, this one is self-explanatory: add spring-security-web jar and give it another try.
  • DarkCoffee
    DarkCoffee almost 10 years
    Yes, it works! Thank you. I got another error but is completely different so I will try to solve it alone.