Error in applicationContext-security.xml

1

My 1st xml file applicationContext-security.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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 auto-config="true">

    <intercept-url pattern="/admin/*" access="ROLE_ADMINISTRADOR" />
    <intercept-url pattern="/restrito/*" access="ROLE_USUARIO" />
    <form-login login-page="/publico/login.jsf"
        always-use-default-target="true" default-target-url="/restrito/principal.jsf"
        authentication-failure-url="/publico/login.jsf?login_error=1" />
    <logout/>
    <remember-me />
</http>

<authentication-manager>
    <authentication-provider>
        <jdbc-user-service data-source-ref="financeiroDataSource"
            authorities-by-username-query="SELECT u.login, p.permissao 
                                         FROM usuario u, usuario_permissao p 
                                        WHERE u.codigo = p.usuario 
                                          AND u.login = ?"
            users-by-username-query="SELECT login, senha, ativo 
                                   FROM usuario 
                                  WHERE login = ?" />
    </authentication-provider>
</authentication-manager>
</b:beans>

And you have this other applicationContext.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" 
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="financeiroDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
        <value>java:comp/env/jdbc/FinanceiroDB</value>
    </property>
</bean>     
</beans>

Everyone is in the WEB-INFO folder.

There are errors in the tomcat log:

1st

GRAVE: Context initialization failed org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [ link / a> Offending resource: ServletContext resource [/WEB-INF/applicationContext-security.xml]

2nd

Sep 09, 2014 9:47:18 PM org.apache.catalina.core.StandardContext listenerStart SERIOUS: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [ link / a> Offending resource: ServletContext resource [/WEB-INF/applicationContext-security.xml]

My libs:

spring-2.5.6.jar
spring-security-cas-3.1.0.RELEASE.jar
spring-security-core-3.1.0.RELEASE.jar
spring-security-openid-3.1.0.RELEASE.jar
spring-security-remoting-3.1.0.RELEASE.jar
spring-security-samples-contacts-3.0.2.RELEASE-sources.jar
spring-security-samples-tutorial-3.0.2.RELEASE-sources.jar

    
asked by anonymous 03.09.2014 / 01:46

1 answer

1

What is happening is as follows, in XML the namespace handler http://www.springframework.org/schema/security is not being found. This is because a library containing this manipulative class is missing.

And for this, the framework library that is missing is: spring-security-config-3.1.0.RELEASE.jar If you see the files inside the META-INF folder of this .jar you will see the files that defines the class that will handle that namespace.

  

So, just add the library mentioned that the error will no longer occur.   However, it is good to add all of the other Spring Security libraries to the project and if you want to reduce the size of .war go remove one at a time to see which ones are not needed.

Other information: link

    
10.09.2014 / 17:31