1
votes

I am trying to implement spring security in my application> I am following this code project tutorial

http://www.codeproject.com/Articles/253901/Getting-Started-Spring-Security

Here my spring-secrity.xml file looks like-

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/security"
    xmlns:bean="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.0.3.xsd">

    <http auto-config='true'>
        <intercept-url pattern="/**" access="ROLE_USER" />
    </http>

    <authentication-manager>
        <authentication-provider>
            <user-service>
                <user name="testadmin" password="testadminpassword"
                    authorities="ROLE_USER, ROLE_ADMIN" />
                <user name="testuser" password="testuserpassword" authorities="ROLE_USER" />
            </user-service>
        </authentication-provider>
    </authentication-manager>

</beans>

But while running the code I am getting the exception-

[2013-08-23 15:27:14,607] ERROR [org.springframework.web.context.ContextLoader] Context initialization failed org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 8 in XML document from ServletContext resource [/WEB-INF/spring-security.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 86; cvc-elt.1: Cannot find the declaration of element 'beans'.

can any one please through the light whats the issue here and also how to rectify it, any help will be appreciated.

2

2 Answers

4
votes

Based on your namespace declarations the <beans> element has to be prefixed with "bean:"

<?xml version="1.0" encoding="UTF-8"?>
<bean:beans ...>
    ...
</bean:beans ...>
0
votes

Two problems here : first : you have to write :

<beans:beans ....
</beans:beans>

second :

xmlns:beans="http://www.springframework.org/schema/beans"

instead of

xmlns:bean="http://www.springframework.org/schema/beans"