Spring Security XML Error - cvc-complex-type.2.4.a: Invalid content was found starting with element 'csrf'

Pankaj Bhambhani

I am using Spring Security in my web application project. I want to enable csrf protection in my Spring application. My application-context-security.xml is as follows

<?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.0.xsd
                        http://www.springframework.org/schema/security
                         http://www.springframework.org/schema/security/spring-security-3.0.xsd">

    <global-method-security secured-annotations="enabled"/> 

    <http disable-url-rewriting="true" auto-config="false" access-decision-manager-ref="accessDecisionManager" entry-point-ref="authenticationEntryPoint">
        <intercept-url pattern="/" access="IS_AUTHENTICATED_ANONYMOUSLY, IS_AUTHENTICATED_FULLY, IS_AUTHENTICATED_REMEMBERED"/>
        <intercept-url pattern="/j_spring_security_check" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
        <intercept-url pattern="/j_spring_security_logout" access="IS_AUTHENTICATED_ANONYMOUSLY, IS_AUTHENTICATED_FULLY, IS_AUTHENTICATED_REMEMBERED"/>
<!-- Enable CSRF protection -->
        <csrf />
    <access-denied-handler ref="accessDeniedHandler"/>         
    </http>
<!-- Remaining information -->
</beans:beans>

I am using Spring 3.0.5 jars for my project.

While running though, I get the following error

SEVERE: Exception sending context initialized event to listener 
instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
 nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: 
Invalid content was found starting with element 'csrf'. 
One of 
'{"http://www.springframework.org/schema/security":intercept-url,
 "http://www.springframework.org/schema/security":access-denied-handler, 
"http://www.springframework.org/schema/security":form-login, 
"http://www.springframework.org/schema/security":openid-login, 
"http://www.springframework.org/schema/security":x509, 
"http://www.springframework.org/schema/security":http-basic, 
"http://www.springframework.org/schema/security":logout, 
"http://www.springframework.org/schema/security":session-management, 
"http://www.springframework.org/schema/security":remember-me, 
"http://www.springframework.org/schema/security":anonymous, 
"http://www.springframework.org/schema/security":port-mappings, 
"http://www.springframework.org/schema/security":custom-filter, 
"http://www.springframework.org/schema/security":request-cache}' 
is expected.

I tried searching for this error on google. I found a couple of similar places, but they both said the error was due to some change in Spring 3.2+. However, in my case I am using Spring 3.0.5.

Any help would be appreciated.

Lorenz Pfisterer

I think the csrf shortcut of spring security was introduced with the version 3.2.0 (see blogpost)

Maybe you should considerate updating your used spring version

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Spring Security XMLエラー-cvc-complex-type.2.4.a:要素「csrf」で始まる無効なコンテンツが見つかりました

分類Dev

cvc-complex-type.2.4.a: complex type with child-element and attributes

分類Dev

原因:org.xml.sax.SAXParseException:cvc-complex-type.2.4.c:要素 'jpa:repositories'の宣言が見つかりません

分類Dev

Spring Security 4 and JSF 2 integration

分類Dev

Spring Security 4 and JSF 2 integration

分類Dev

Springコンテキストエラー:SAXParseException cvc-complex-type.3.2.2 ignore-unresolvable context:property-placeholder

分類Dev

error in spring-security.xml for constructor arg error

分類Dev

cvc-complex-type.4:属性{0}は要素{1}に表示される必要があります

分類Dev

XML .xsd invalid element

分類Dev

Getting error from spring-security.xml in case of multi-tenacy with Oauth,SAML, and spring-security

分類Dev

Spring Data with QueryDslPredicateExecutor no property findAll found for type error

分類Dev

Spring Data with QueryDslPredicateExecutor no property findAll found for type error

分類Dev

Spring Data with QueryDslPredicateExecutor no property findAll found for type error

分類Dev

Http response Content-Type is json. Error for "Invalid mime type"

分類Dev

Maven:Spring 4 + Spring Security

分類Dev

web.xmlのエラー:cvc-complex-type.2.4.a:要素 'context-root'で始まる無効なコンテンツが見つかりました

分類Dev

org.xml.sax.SAXParseException;cvc-complex-type.2.4.c: 一致するワイルドカードは厳密ですが、宣言が見つかりません

分類Dev

Django CSRF cookie not set error if there is cookie value starting with square brackets '['

分類Dev

XML検証の問題(S4s-elt-invalid-content.1)

分類Dev

Spring Security OAuth2: how to add multiple Security Filter Chain of type ResourceServerConfigurer?

分類Dev

cvc-complex-type.2.4.b:要素 'tns:patient'の内容が完全ではありません

分類Dev

Element type is invalid: expected a string (for built-in components) or a class/function React Error

分類Dev

Element type is invalid: expected a string (for built-in components) or a class/function React Error

分類Dev

Cant start React simple app I get Error: Element type is invalid: expected a string

分類Dev

React-Router 1.0.0 Uncaught Error:Invariant Violation:Element type is invalid

分類Dev

Spring Security 4xml構成UserDetailsService認証が機能しない

分類Dev

Video content type is invalid in paperclip-ffmpeg

分類Dev

CSRF detection for POST request with content type validation at server

分類Dev

Invariant Violation: Element type is invalid: expected a string

Related 関連記事

  1. 1

    Spring Security XMLエラー-cvc-complex-type.2.4.a:要素「csrf」で始まる無効なコンテンツが見つかりました

  2. 2

    cvc-complex-type.2.4.a: complex type with child-element and attributes

  3. 3

    原因:org.xml.sax.SAXParseException:cvc-complex-type.2.4.c:要素 'jpa:repositories'の宣言が見つかりません

  4. 4

    Spring Security 4 and JSF 2 integration

  5. 5

    Spring Security 4 and JSF 2 integration

  6. 6

    Springコンテキストエラー:SAXParseException cvc-complex-type.3.2.2 ignore-unresolvable context:property-placeholder

  7. 7

    error in spring-security.xml for constructor arg error

  8. 8

    cvc-complex-type.4:属性{0}は要素{1}に表示される必要があります

  9. 9

    XML .xsd invalid element

  10. 10

    Getting error from spring-security.xml in case of multi-tenacy with Oauth,SAML, and spring-security

  11. 11

    Spring Data with QueryDslPredicateExecutor no property findAll found for type error

  12. 12

    Spring Data with QueryDslPredicateExecutor no property findAll found for type error

  13. 13

    Spring Data with QueryDslPredicateExecutor no property findAll found for type error

  14. 14

    Http response Content-Type is json. Error for "Invalid mime type"

  15. 15

    Maven:Spring 4 + Spring Security

  16. 16

    web.xmlのエラー:cvc-complex-type.2.4.a:要素 'context-root'で始まる無効なコンテンツが見つかりました

  17. 17

    org.xml.sax.SAXParseException;cvc-complex-type.2.4.c: 一致するワイルドカードは厳密ですが、宣言が見つかりません

  18. 18

    Django CSRF cookie not set error if there is cookie value starting with square brackets '['

  19. 19

    XML検証の問題(S4s-elt-invalid-content.1)

  20. 20

    Spring Security OAuth2: how to add multiple Security Filter Chain of type ResourceServerConfigurer?

  21. 21

    cvc-complex-type.2.4.b:要素 'tns:patient'の内容が完全ではありません

  22. 22

    Element type is invalid: expected a string (for built-in components) or a class/function React Error

  23. 23

    Element type is invalid: expected a string (for built-in components) or a class/function React Error

  24. 24

    Cant start React simple app I get Error: Element type is invalid: expected a string

  25. 25

    React-Router 1.0.0 Uncaught Error:Invariant Violation:Element type is invalid

  26. 26

    Spring Security 4xml構成UserDetailsService認証が機能しない

  27. 27

    Video content type is invalid in paperclip-ffmpeg

  28. 28

    CSRF detection for POST request with content type validation at server

  29. 29

    Invariant Violation: Element type is invalid: expected a string

ホットタグ

アーカイブ