Could not find Spring namespace namespace for XML schema space [http://www.springframework.org/schema/security]

I am developing my first spring security application. The applicationContext-security.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?> <!-- - Namespace-based OpenID configuration --> <b:beans xmlns="http://www.springframework.org/schema/security" xmlns:b="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"> <http> <intercept-url pattern="/**" access="ROLE_USER"/> <intercept-url pattern="/index.xhtml*" filters="none"/> <logout/> <openid-login login-page="/index.xhtml" authentication-failure-url="/index.xhtml?login_error=true"> <attribute-exchange> <openid-attribute name="email" type="http://schema.openid.net/contact/email" required="true" count="2"/> <openid-attribute name="name" type="http://schema.openid.net/namePerson/friendly" /> </attribute-exchange> </openid-login> <remember-me token-repository-ref="tokenRepo"/> </http> <b:bean id="tokenRepo" class="org.springframework.security.web.authentication.rememberme.InMemoryTokenRepositoryImpl" /> <authentication-manager alias="authenticationManager"/> <user-service id="userService"> <user name="http://user.myopenid.com/" authorities="ROLE_SUPERVISOR,ROLE_USER" /> </user-service> </b:beans> 

and Web.xml file:

 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>Spring Security OpenID Demo Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext-security.xml </param-value> </context-param> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/classes/log4j.properties</param-value> </context-param> <context-param> <param-name>webAppRootKey</param-name> <param-value>openid.root</param-value> </context-param> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <welcome-file-list> <welcome-file>faces/index.xhtml</welcome-file> </welcome-file-list> </web-app> 

The application cleanup and build was successful, but when I try to deploy the jetty 7 application it gives me the following error:

SEVERE: Context initialization error
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: configuration problem: cannot find spring namespace for XML schema namespace [ http://www.springframework.org/schema/security]
Offensive resource: ServletContext resource [/WEB-INF/applicationContext-security.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error (FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error (ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error (ReaderContext.java:80)

I tried everything, but could not solve this error. Any help would be appreciated.

EDIT I tried to add version 3.0.2 of Spring-Security 3.0.2 and got the following:

Context Initialization Error
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: line 13 in the XML document from the ServletContext resource [/WEB-INF/applicationContext-security.xml] is invalid; The nested exception is org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 11; cvc-complex-type.2.4.c: The corresponding template is strict, but no declaration was found for the http element. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions (XmlBeanDefinitionReader.javahaps96)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions (XmlBeanDefinitionReader.java data34

+53
spring spring-security
Aug 25 '11 at 10:22
source share
3 answers

You need spring-security-config.jar in your classpath.

An exception means that security: xml namescape cannot be processed using spring parsers. They are implementations of the NamespaceHandler interface, so you need a handler that knows how to handle <security: tags. What SecurityNamespaceHandler is in spring-security-config

+87
Aug 25 2018-11-11T00:
source

I had the same problem. The only thing that allowed this was to combine the contents of META-INF / spring.handler and META-INF / spring. The schemas of each spring jar file into the same file names in my META-INF project.

These two threads explain this better:

+7
Sep 14
source

In my case, this was triggered by custom manifest entries added by maven-jar-plugin.

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <configuration> <archive> <index>true</index> <manifest> <addClasspath>true</addClasspath> </manifest> <manifestEntries> <git>${buildNumber}</git> <build-time>${timestamp}</build-time> </manifestEntries> </archive> </configuration> </plugin> 

Removing the following items fixed the problem

 <index>true</index> <manifest> <addClasspath>true</addClasspath> </manifest> 
0
Apr 6 '16 at 20:22
source



All Articles