huahsin68
huahsin68

Reputation: 6979

Spring security http and authentication-provider not declared

I was trying to integrating Spring security into my existing project. The tools that I am using are:

  1. Spring 2.5.6.SEC03
  2. spring-security-core 3.1.1.RELEASE
  3. JDK 7.

In spring configuration, I have this:

<beans:beans xmlns="http://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.1.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">

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

<authentication-provider>
  <user-service>
    <user name="user1" password="1111" authorities="ROLE_USER"/>
  </user-service>
</authentication-provider>
</beans:beans>

But there is an error on this spring configuration:

  1. cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'authentication-provider'.
  2. cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'http'.

May I know how to resolve this issue?

Upvotes: 3

Views: 5650

Answers (1)

shazinltc
shazinltc

Reputation: 3666

MaKe these changes

<?xml version="1.0" encoding="UTF-8"?>
<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.1.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-3.1.xsd">

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

  <authentication-manager>
    <authentication-provider>
      <user-service>
        <user name="user1" password="1111" authorities="ROLE_USER"/>
      </user-service>
    </authentication-provider>
  </authentication-manager>

</beans:beans>

I have done the following changes

  1. Changed your xmlns schema from "http://springframework.org/schema/security"to "http://www.springframework.org/schema/security" (added www :D)
  2. I have enclosed the <authentication-provider> namespace inside a <authentication-manager> namespace.

Upvotes: 8

Related Questions