0

I'm trying to configure Spring security declaratively using the Spring 4. I created the file applicationContext-security.xml as the image below show

applicationContext-security

When I'm running the application I'm still having the same error like

Failed to instantiate [org.springframework.security.config.SecurityNamespaceHandler]: Constructor threw exception. Check Error Log for more details.

Did someone already faced that issue ? Could you please help me to fix this issue ? Thanks in advance.

yimson
  • 49
  • 2
  • 14
  • What's the `Error Log` ? – chaoluo Jan 03 '17 at 01:03
  • GRAVE: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [applicationContext-security.xml] – yimson Jan 03 '17 at 01:25
  • Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext-security.xml]; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.config.SecurityNamespaceHandler]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/config/AbstractInterceptorDrivenBeanDefinitionDecorator – yimson Jan 03 '17 at 01:25

2 Answers2

0

maybe you added more than one version of spring secuirty check your dependencies, I faced this issue and I solved it by removing other dependencies.

S.Ozer
  • 17
  • 7
-1

Missing the spring-aop jar.

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>4.3.5.RELEASE</version>
</dependency>
chaoluo
  • 2,596
  • 1
  • 17
  • 29
  • After putting the spring-aop jar, I'm facing the following error now : Multiple annotations found at this line: - Configuration problem: You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd or spring-security-3.1.xsd schema or spring-security-3.2.xsd schema or spring-security-4.0.xsd schema with Spring Security 4.1. Please update your schema declarations to the 4.1 schema. Offending resource: file [E:/projects/workspace/gyy-website/WebContent/WEB-INF/applicationContext-security.xml] – yimson Jan 03 '17 at 01:38
  • - You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd or spring-security-3.1.xsd schema or spring-security-3.2.xsd schema or spring-security-4.0.xsd schema with Spring Security 4.1. Please update your schema declarations to the 4.1 schema. – yimson Jan 03 '17 at 01:39
  • update your xsd version to 4.1 in applicationContext-security.xml. – chaoluo Jan 03 '17 at 01:40
  • Thank you so much, the following problem has been solved Failed to instantiate [org.springframework.security.config.SecurityNamespaceHandler]: Constructor threw exception. Check Error Log for more details. – yimson Jan 03 '17 at 01:44
  • It is recommended to use the "versionless" XSDs, because they're mapped to the current version of the framework you're using in your application. see [here](http://stackoverflow.com/questions/20894695/spring-configuration-xml-schema-with-or-without-version) – chaoluo Jan 03 '17 at 01:45