Fórum Segurança usando Spring Security 3.0 #408007
26/09/2011
0
Aqui tem os arquivos: web.xml, applicationContext.xml, spring-security-config.xml e erros em Console.
Régis Santos
Curtir tópico
+ 0Posts
26/09/2011
Régis Santos
Aqui tem os arquivos: web.xml, applicationContext.xml, spring-security-config.xml e erros em Console.
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
xmlns:context=http://www.springframework.org/schema/context
xmlns:aop=http://www.springframework.org/schema/aop
xmlns:tx=http://www.springframework.org/schema/tx
xsi:schemaLocation=http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd>
<bean id=dataSource class=config.Conexao />
<bean id=sessionFactory class=org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
scope=singleton lazy-init=false autowire=default>
<property name=dataSource ref=dataSource />
<property name=hibernateProperties>
<props>
<prop key=hibernate.dialect>org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key=hibernate.transaction.factory_class>org.hibernate.transaction.JDBCTransactionFactory</prop>
<prop key=hibernate.show_sql>true</prop>
<prop key=hibernate.hbm2ddl.auto>update</prop>
<prop key=c3p0.acquire_increment>1</prop>
<prop key=c3p0.idle_test_period>120</prop>
<prop key=c3p0.max_size>50</prop>
<prop key=c3p0.max_statements>100</prop>
<prop key=c3p0.min_size>5</prop>
<prop key=c3p0.timeout>150</prop>
</props>
</property>
<property name=annotatedClasses>
<list>
<value>entidade.Pais</value>
<value>entidade.Produto</value>
<value>entidade.Produto</value>
<value>entidade.Uf</value>
<value>entidade.Estoque</value>
<value>entidade.Cidade</value>
<value>entidade.Fabricante</value>
<value>entidade.ItemVendido</value>
<value>entidade.Venda</value>
<value>entidade.Representante</value>
<value>entidade.Envio</value>
<value>entidade.CartaoCredito</value>
<value>entidade.Cliente</value>
<value>entidade.Usuario</value>
<value>entidade.Perfil</value>
<value>entidade.Configuracao</value>
</list>
</property>
</bean>
<bean class=seguranca.TesteEventListener/>
<bean id=transactionManager
class=org.springframework.orm.hibernate3.HibernateTransactionManager>
<property name=sessionFactory><ref local=sessionFactory/></property>
</bean> -->
<context:annotation-config/>
<context:component-scan base-package=dao, controle, modelo />
</beans> arquivo: spring-security-config.xml
<?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.0.xsd>
<http auto-config=true access-denied-page=/accessoNegado.jsp>
<intercept-url pattern=/usuarios/** access=ROLE_USUARIO, ROLE_ADMIN/>
<intercept-url pattern=/administrador/** access=ROLE_ADMIN/>
<form-login login-page=/login.jsp authentication-failure-url=login.jsp?login_error=true
default-target-url=/index.jsp/>
<logout logout-url=/logout/>
</http>
<authentication-manager>
<authentication-provider user-service-ref=hibernateUserDetailsService ref=daoAuthenticationProvider />
</authentication-manager>
<beans:bean id=daoAuthenticationProvider class=org.springframework.security.authentication.dao.DaoAuthenticationProvider>
<beans:property name=userDetailsService ref=hibernateUserDetailsService />
</beans:bean>
<beans:bean class=seguranca.EventListenerSenhaIncorreta/>
<beans:bean class=org.springframework.security.event.authorization.LoggerListener/>
<beans:bean class=org.springframework.security.event.authorization.LoggerListener/>
</beans:beans>arquivo: web.xml
<?xml version=1.0 encoding=UTF-8?>
<web-app xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns=http://java.sun.com/xml/ns/javaee xmlns:web=http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd xsi:schemaLocation=http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd id=WebApp_ID version=3.0>
<display-name>regisecommerce</display-name>
<servlet>
<servlet-name>meuEcommerce</servlet-name>
<servlet-class>classeGeral.MeuEcommerce</servlet-class>
</servlet>
<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>
<!-- Configuracão do Spring -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml
/WEB-INF/spring-security-config.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>email</param-name>
<param-value>regisosantos@yahoo.com.br</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>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: client or server (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>Erros mostrados em CONSOLE:
26/09/2011 16:28:33 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Arquivos de programas\Java\jdk1.6.0_21\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Documents and Settings/Eu Regis/jdk6/bin/client;C:/Documents and Settings/Eu Regis/jdk6/bin;C:/Documents and Settings/Eu Regis/jdk6/lib/i386;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Arquivos de programas\Smart Projects\IsoBuster;C:\Arquivos de programas\TortoiseSVN\bin;C:\Arquivos de programas\Subversion\bin;C:\Arquivos de Programas\java\jdk1.6.0_21\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Arquivos de programas\Smart Projects\IsoBuster;C:\Arquivos de programas\TortoiseSVN\bin;C:\Arquivos de programas\Subversion\bin
26/09/2011 16:28:34 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVISO: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property source to org.eclipse.jst.jee.server:regisecommerce did not find a matching property.
26/09/2011 16:28:34 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
26/09/2011 16:28:34 org.apache.coyote.ajp.AjpProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009
26/09/2011 16:28:34 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1715 ms
26/09/2011 16:28:34 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
26/09/2011 16:28:34 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.2
26/09/2011 16:29:14 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener com.sun.faces.config.ConfigureListener is already configured for this context. The duplicate definition has been ignored.
26/09/2011 16:29:14 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
26/09/2011 16:29:21 org.apache.catalina.core.StandardContext listenerStart
GRAVE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name cartaoCreditoDAO: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory dao.GenericoDAO.sessionFactory; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.event.authorization.LoggerListener] for bean with name org.springframework.security.event.authorization.LoggerListener#0 defined in ServletContext resource [/WEB-INF/spring-security-config.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.event.authorization.LoggerListener
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4323)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4780)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:771)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:427)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:649)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory dao.GenericoDAO.sessionFactory; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.event.authorization.LoggerListener] for bean with name org.springframework.security.event.authorization.LoggerListener#0 defined in ServletContext resource [/WEB-INF/spring-security-config.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.event.authorization.LoggerListener
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
... 33 more
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.event.authorization.LoggerListener] for bean with name org.springframework.security.event.authorization.LoggerListener#0 defined in ServletContext resource [/WEB-INF/spring-security-config.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.event.authorization.LoggerListener
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1319)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:315)
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:185)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:829)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
... 35 more
Caused by: java.lang.ClassNotFoundException: org.springframework.security.event.authorization.LoggerListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1666)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:257)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1271)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1242)
... 43 more
26/09/2011 16:29:21 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Inicializando Mojarra 2.1.1 (FCS 20110408) para o contexto /regisecommerce
26/09/2011 16:29:23 com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: Anotações PostConstruct/PreDestroy presentes. Os métodos ManagedBeans marcados com essas anotações informarão as anotações processadas.
26/09/2011 16:29:24 org.apache.catalina.core.StandardContext startInternal
GRAVE: Error listenerStart
26/09/2011 16:29:24 org.apache.catalina.core.StandardContext startInternal
GRAVE: Context [/regisecommerce] startup failed due to previous errors
26/09/2011 16:29:24 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
26/09/2011 16:29:24 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
GRAVE: The web application [/regisecommerce] registered the JBDC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
26/09/2011 16:29:24 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
GRAVE: The web application [/regisecommerce] created a ThreadLocal with key of type [null] (value [javax.faces.context.FacesContext$1@17ec251]) and a value of type [com.sun.faces.config.InitFacesContext] (value [com.sun.faces.config.InitFacesContext@1077c9d]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Gostei + 0
26/09/2011
Davi Costa
exception is java.lang.ClassNotFoundException: org.springframework.security.event.authorization.LoggerListener
procure o jar que contém essa classe org.springframework.security.event.authorization.LoggerListener
Dica:
http://www.jarfinder.com/
att Davi
Gostei + 0
27/09/2011
Dyego Carmo
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)