Ajuda com Spring Security

11 respostas
L

Boa Noite, alguém manja de como trabalhar com spring Security, estou com esse erro:

Grave: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.security.filterChains’: Cannot resolve reference to bean ‘org.springframework.security.web.DefaultSecurityFilterChain#0’ while setting bean property ‘sourceList’ with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.security.web.DefaultSecurityFilterChain#0’: Cannot resolve reference to bean ‘org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0’ while setting constructor argument with key [2];

11 Respostas

T

como esta seu

applicationContext.xml (arquivo onde fica a config. do spring)
web.xml

passe ele ai

F

aproveita e fala também em qual momento dá erro. se é na compilação, se é quando acessa alguma opção. Quanto mais informações, mais fácil fica de te ajudarmos.

L
tmvolpato:
como esta seu

applicationContext.xml (arquivo onde fica a config. do spring)
web.xml

passe ele ai

WEB.XML

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
    <context-param>  
        <param-name>primefaces.THEME</param-name>  
        <param-value>start</param-value>  
    </context-param>
   
    <!-- Início das configurações para o Spring Security 3 -->
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
 
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!-- Fim das configuração para utilizar o Spring Security 3 -->
   
</web-app>
APLICATIONCONTEXT
<?xml version="1.0" encoding="UTF-8"?>
<b:beans xmlns="http://www.springframework.org/schema/security"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:b="http://www.springframework.org/schema/beans"
        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-3.1.xsd">

    <http auto-config="true" use-expressions="true">
        <intercept-url pattern="/faces/admin/**" access="hasRole('ROLE_ADMIN')"/>
        <form-login login-page="/faces/login.xhtml" authentication-failure-url="/login.xhtml?erro=true"/>
    </http>
    
    <authentication-manager>
        <authentication-provider> 
            <password-encoder hash="md5"/>  
            <jdbc-user-service data-source-ref="dataSource"
               users-by-username-query="SELECT su.usuario as username, su.senha as
                password, 'true' as enable FROM usuarios su WHERE su.usuario=?"
            authorities-by-username-query="SELECT u.usuario as username, u.permissao 
                as authority FROM usuarios u WHERE u.usuario=?"
            />
        </authentication-provider>
    </authentication-manager>

    <b:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
        <b:property name="url" value="jdbc:postgresql://localhost:5432/db_sistema" />
        <b:property name="driverClassName" value="org.postgresql.Driver" />
        <b:property name="username" value="postgres" />
        <b:property name="password" value="123" />
    </b:bean>

</b:beans>

esses sao o aplicationContext e o web.xml

L

o erro acontece na hora da compilação

T

você está usando jsf?

L

jsf, hibernate e primefaces

T

passe seu faces-config.xml tbm

L

Cara eu estou usando Annotations

T

Cara eu estou usando Annotations

entao, qdo você tem uma aplicação jsf
precisa declarar uma classe do spring nesse arquivo faces-config.xml que é do jsf

L

cara vc poderia me da um exemplo de como seria, sou novo no assunto

L

Alguém possui um tutorial, passo a passo de como implementar o spring security ?

Criado 11 de setembro de 2013
Ultima resposta 13 de set. de 2013
Respostas 11
Participantes 3