Spring Security - Unexpected exception parsing XML document from URL

Olá,

Estou implantando Spring Security em minha aplicação web.
Uso Spring 2.5 e to usando Spring Security 2.0.4.
Segui varios tutoriais… o projeto nao contem nenhum erro… mas quando tentou rodar… aparece isso na console

[psiconline.webapp] [ERROR] ContextLoader.initWebApplicationContext(215) | Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL [file:/C:/Documents%20and%20Settings/doliveira/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/psiconline-web/WEB-INF/classes/META-INF/spring-security.xml]; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/Signature at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:578) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Caused by: java.lang.NoClassDefFoundError: org/aspectj/lang/Signature at org.springframework.security.config.GlobalMethodSecurityBeanDefinitionParser.parse(GlobalMethodSecurityBeanDefinitionParser.java:58) at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398) ... 28 more Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.Signature at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 36 more

Estou usando Maven para importar os Jars. Estes sao os Jar que estou utilizando do Spring Security

<dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-acl</artifactId> <version>2.0.4</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>2.0.4</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core-tiger</artifactId> <version>2.0.4</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-taglibs</artifactId> <version>2.0.4</version> </dependency>

Segue abaixo tambem meu spring-security.xml

[code]<?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-2.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.1.xsd”>

<global-method-security secured-annotations="enabled">
</global-method-security>

<http auto-config="true" access-denied-page="/accessDenied.jsp">

	<!-- Restrict URLs based on role -->
	<intercept-url pattern="/protected/user/**" access="ROLE_USER" />
	<!--
		Seus papeis no sistema (roles) e as pastas que possuem acesso
	-->
	<intercept-url pattern="/protected/adm/**" access="ROLE_ADM" />
	<intercept-url pattern="/protected/**" access="ROLE_USER, ROLE_ADM" />

	<form-login login-processing-url="/j_spring_security_check"
		login-page="/login" default-target-url="/"
		authentication-failure-url="/login" />
	<logout logout-url="/logout" logout-success-url="/" />
</http>

<authentication-provider>
</authentication-provider>

</beans:beans>[/code]

Alguem poderia me ajudar porfa…

Se alguem tiver um outro tutorial que posso seguir… algo assim… agradeço…

Se precisar de mais detalhes d minha aplicacao … eu posto aki

Muito Obrigado…

inclua no seu pom.xml

	<dependency>
	    <groupId>org.aspectj</groupId>
	    <artifactId>aspectjweaver</artifactId>
	    <version>1.6.6</version>
	</dependency>

Ricardo…

Eu inclui essa dependencia e apareceu este novo erro:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: A user-service is required Offending resource: URL [file:/C:/Documents%20and%20Settings/doliveira/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/psiconline-web/WEB-INF/classes/META-INF/spring-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:72) at org.springframework.security.config.AuthenticationProviderBeanDefinitionParser.parse(AuthenticationProviderBeanDefinitionParser.java:78) at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:578) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

este é meu spring-security.xml

[code]<?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-2.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.4.xsd”>

<global-method-security secured-annotations="enabled">
</global-method-security>

<http auto-config="true" access-denied-page="/accessDenied.jsp">

	<!-- Restrict URLs based on role -->
	<intercept-url pattern="/protected/user/**" access="ROLE_USER" />
	<!--
		Seus papeis no sistema (roles) e as pastas que possuem acesso
	-->
	<intercept-url pattern="/protected/adm/**" access="ROLE_ADM" />
	<intercept-url pattern="/protected/**" access="ROLE_USER, ROLE_ADM" />

	<form-login login-processing-url="/j_spring_security_check"
		login-page="/login" default-target-url="/"
		authentication-failure-url="/login" />
	<logout logout-url="/logout" logout-success-url="/" />
</http>

<authentication-provider>
</authentication-provider>

</beans:beans>[/code]

post seu web.xml

ele deve conter[code]
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

&lt;filter&gt;
    &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
    &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
&lt;/filter&gt;

&lt;filter-mapping&gt;
  &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
  &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;[/code]

Esta é meu web.xml

[code]

<display-name>Psiconline</display-name>

<!-- Localização do(s) arquivo(s) de configuração do Spring -->
<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>
		classpath*:/META-INF/applicationContext.xml
		classpath*:/META-INF/spring-security.xml
    </param-value>
</context-param>


<!-- Spring Security -->
<filter>
	<filter-name>springSecurityFilterChain</filter-name>
	<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>




<!-- Configuração do filtro usado para criar uma sessão do hibernate

–>

lazyLoadingFilter
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter

<filter-mapping>
	<filter-name>lazyLoadingFilter</filter-name>
	<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Spring Security -->
<filter-mapping>
	<filter-name>springSecurityFilterChain</filter-name>
	<url-pattern>/*</url-pattern>
</filter-mapping>




<!--
	Listeners utilizados para inicializar o framework Spring. Ver
	arquivo(s) de configuração declarados anteriormente
-->
<listener>
	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
	<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

[/code]

Me parece tambem algum erro de UserDetailsService…

Eu tenho uma classe chamada CustomUserDetailsService.java
Eu tenho que setar ela em algum xml… applicationContect.xml??

obrigado

O conteúdo do seu authentication-provider está todo “comentado”. Ou seja, vazio.
Você precisa dizer onde vai pegar as informações do usuário a ser autenticado. Ao menos um user-service.

exemplo: &lt;authentication-provider&gt; &lt;jdbc-user-service data-source-ref="dataSource" users-by-username-query="SELECT U.username, U.password, U.accountEnabled AS 'enabled' FROM User U where U.username=?" authorities-by-username-query="SELECT U.username, R.name as 'authority' FROM User U JOIN Authority A ON u.id = A.userId JOIN Role R ON R.id = A.roleId WHERE U.username=?"/&gt; &lt;/authentication-provider&gt;

Como ficaria para PostGreSQL ?

&lt;security:authentication-manager alias="authManager"&gt; &lt;security:authentication-provider&gt; &lt;security:password-encoder hash="plaintext"/&gt; &lt;security:jdbc-user-service data-source-ref="dataSource" users-by-username-query="" authorities-by-username-query=""/&gt; &lt;/security:authentication-provider&gt; &lt;/security:authentication-manager&gt;

aqui segue a conecção :

&lt;!-- DataSource PostgreSQL --&gt; &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close"&gt; &lt;property name="driverClassName" value="org.postgresql.Driver"/&gt; &lt;property name="url" value="jdbc:postgresql://localhost:5432/nutec"/&gt; &lt;property name="username" value="root"/&gt; &lt;property name="password" value="debian23"/&gt;

eu sabia que este dia iria chegar, só não esperava que seria tão cedo

da forma que me foi recomendado, não vou perder a chance

http://guj.com.br/posts/list/214001.java#1090122

ricardosoares ? o que você quis dizer ?