Spring 3.0 - Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security] Spring 3.0 - Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security] spring spring

Spring 3.0 - Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]


I needed to add an additional Maven dependency:

    <dependency>        <groupId>org.springframework.security</groupId>        <artifactId>spring-security-config</artifactId>        <version>3.0.1.RELEASE</version>    </dependency>


I had the same error message while trying to deploy the application. In Spring, the security configuration xml can be a different one from applicationContext.xml, usually applicationContext-security.xml inside WEB-INF folder. The changes to be applied are for web.xml

<context-param>    <param-name>contextConfigLocation</param-name>    <param-value>        /WEB-INF/applicationContext.xml        /WEB-INF/applicationContext-security.xml    </param-value></context-param>

And the applicationContext.xml would look like:

<?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.1.xsd">    <http auto-config='true'>        <intercept-url pattern="/login.jsp" access="IS_AUTHENTICATED_ANONYMOUSLY"/>        <intercept-url pattern="/**" access="ROLE_USER" />        <form-login login-page='login.jsp'/>    </http></beans:beans>

Even after you make these changes, the namespace error will exist. To get rid of this, add the following jar files to the WEB-INF/lib and then to the library:

  • spring-security-acl-3.1.0.M2.jar
  • spring-security-config-3.1.0.M2.jar
  • spring-security-core-3.1.0.M2.jar
  • spring-security-taglibs-3.1.0.M2.jar
  • spring-security-web-3.1.0.M2.jar


I struggled with this for a while and none of these answers helped. Thanks to the comment from user64141 I realised that there was a problem with the spring.handlers files.

I am using the Shade plugin for Maven to generate a fat jar, and all the spring.handlers (and spring.schemas) files were being overwritten by each Spring dependency.

The Maven site covers this exact problem and how to solve it by appending the files together instead:

http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#AppendingTransformer