4

I am not able to solve this problem that I have XSD version above 4 then why there is still conflict?

I am using Spring JARs and all of them have version 4 or above and still getting error.

Following is XSD for spring-security.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.1.xsd">
    <security:http auto-config="true">  <!-- ////this line holds error/////-->
        <security:intercept-url pattern="/"
            access="hasRole('ROLE_ADMIN')" />
        <security:form-login login-page="/login"
            default-target-url="/" authentication-failure-url="/loginerror" />
        <security:logout logout-success-url="/logout" />
        <security:csrf disabled="true" />
    </security:http>
    <security:authentication-manager>
        <security:authentication-provider>
            <security:user-service>
                <security:user name="admin" authorities="ROLE_ADMIN"
                    password="admin" />
            </security:user-service>
        </security:authentication-provider>
    </security:authentication-manager>
</beans> 

and following is the error:

Multiple annotations found at this line: - Configuration problem: You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd schema with Spring Security 3.1. Please update your schema declarations to the 3.1 schema. Offending resource: file [C:/Documents and Settings/Administrator/My Documents/Google Drive/spring_workspace/spring security_demo/WebContent/WEB-INF/security-context.xml] - You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd schema with Spring Security 3.1. Please update your schema declarations to the 3.1 schema.

and this is my schema for dispatcher servlet:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">

First I thought I have conflicts in my both mentioned .xsd files but now both ' .xsd' files have same schema.

Edit: Event details

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd schema with Spring Security 3.1. Please update your schema declarations to the 3.1 schema. Offending resource: file [C:/Documents and Settings/Administrator/My Documents/Google Drive/spring_workspace/spring security_demo/WebContent/WEB-INF/security-context.xml]

at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$BeansConfigProblemReporter.fatal(BeansConfig.java:1137)

at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:68)

at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:55)

at org.springframework.security.config.SecurityNamespaceHandler.parse(SecurityNamespaceHandler.java:66)

at org.springframework.ide.eclipse.beans.core.internal.model.namespaces.DelegatingNamespaceHandlerResolver$ElementTrackingNamespaceHandler.parse(DelegatingNamespaceHandlerResolver.java:177)

at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1411)

at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1428)

at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1401)

at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:172)

at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ToolingFriendlyBeanDefinitionDocumentReader.doRegisterBeanDefinitions(BeansConfig.java:1357)

at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)

at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.registerBeanDefinitions(BeansConfig.java:410)

How to solve that?

dur
  • 13,039
  • 20
  • 66
  • 96

1 Answers1

2

Your exception says

You should not use 4.1 xsd,since your spring security version is 3.1

In below line you have mentioned spring security version as 4.1,it should be 3.1

 http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.1.xsd">

Two ways to solve

  1. Change to http://www.springframework.org/schema/security/spring-security-3.1.xsd
  2. Remove version so that spring will take automatically http://www.springframework.org/schema/security/spring-security.xsd

Update : Add use-expressions attribute to http.Since you are using expression hasRole('Role_Admin') you have to provide this.

<security:http auto-config="true" use-expressions="true">
Prasanna Kumar H A
  • 2,923
  • 4
  • 20
  • 46
  • stll leading me to same `MatcherType` I am using eclipse `neon` if that is causing problem ? –  Sep 24 '16 at 09:12
  • No..make sure you have `spring-security-web-3.1.X.RELEASE.jar from your classpath`..can you paste entire stacktrace..update the question – Prasanna Kumar H A Sep 24 '16 at 09:18
  • @HelloWorld change your url to `/**` ` in ` – Prasanna Kumar H A Sep 24 '16 at 09:26
  • 1
    actually when I tried in mars its working but not in eclipse `neon` –  Sep 24 '16 at 09:48
  • 1
    `neon` is creating `error log` in `.metadata` and I think I should jump back to `mars` until a stable `build` comes out and Thanks for your time too. –  Sep 24 '16 at 09:53
  • 1
    and it is causing error in every possible `configuration` file –  Sep 24 '16 at 09:54
  • @dur I think you are right in other IDE `sts` is not installed –  Sep 24 '16 at 10:13
  • @dur its still getting me `Internal Error` after removing `STS` and now I'm moving to `eclipse mars` :) –  Sep 24 '16 at 10:22