Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » [SOLVED] AspectJ Weaver error on @Aspect(Using AspectJ LTW in adiction with Spring AOP)
[SOLVED] AspectJ Weaver error on @Aspect [message #1004841] Wed, 23 January 2013 20:03 Go to next message
Eduardo Frazão is currently offline Eduardo Frazão
Messages: 108
Registered: January 2012
Senior Member
Hi folks. Im trying to write a simple aspect, that will intercept classes on the same bundle, but this is not working.

Here is my Aspect:

@Aspect
@Component
public class LoginLoggerAspect {

	@Pointcut("execution(* br.com.autmix.domain.spi.impl.security.LoginServiceImpl.login(..))")
	public void onLogin() {}
		
	@AfterThrowing(
			pointcut = "onLogin()",
			throwing = "ex"
			)
	public void logarTentativaFalha(AuthenticationException ex) {
		if(ex.getUsuario() != null) {
                       // some behavior
		} else {
	               // another behavior
		}
	}
		
}



On the bundle startup I got this error:

 [Xlint:cantFindType]
	at org.eclipse.virgo.kernel.deployer.core.internal.BlockingSignal.awaitCompletion(BlockingSignal.java:87)
	at org.eclipse.virgo.kernel.deployer.core.internal.BlockingAbortableSignal.awaitCompletion(BlockingAbortableSignal.java:63)
	at org.eclipse.virgo.kernel.install.artifact.internal.bundle.StandardBundleInstallArtifact.startIfNecessary(StandardBundleInstallArtifact.java:440)
	at org.eclipse.virgo.kernel.install.artifact.internal.bundle.StandardBundleInstallArtifact.doRefresh(StandardBundleInstallArtifact.java:431)
	at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.refresh(AbstractInstallArtifact.java:565)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.refreshArtifact(PipelinedApplicationDeployer.java:274)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.refreshExistingArtifact(PipelinedApplicationDeployer.java:232)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.doInstall(PipelinedApplicationDeployer.java:151)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.install(PipelinedApplicationDeployer.java:140)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.deploy(PipelinedApplicationDeployer.java:253)
	at org.eclipse.virgo.kernel.deployer.management.StandardDeployer.deploy(StandardDeployer.java:52)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:192)
	at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:174)
	at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:117)
	at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:54)
	at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:235)
	at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
	at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:250)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:791)
	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1486)
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:96)
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1327)
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1419)
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:847)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
	at sun.rmi.transport.Transport$1.run(Transport.java:177)
	at sun.rmi.transport.Transport$1.run(Transport.java:174)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalArgumentException: warning can't determine implemented interfaces of missing type br.com.autmix.domain.aspect.log.LoginLoggerAspectImpl
 [Xlint:cantFindType]
	at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301)
	at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207)
	at org.springframework.aop.aspectj.AspectJExpressionPointcut.getFallbackPointcutExpression(AspectJExpressionPointcut.java:358)
	at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:255)
	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:209)
	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:263)
	at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:295)
	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1461)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:60)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:325)
	at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:290)
	at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)
	at org.eclipse.virgo.kernel.agent.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:95)
	... 3 common frames omitted


This is my context configuration:

<context:load-time-weaver aspectj-weaving="on"/>
	<aop:aspectj-autoproxy />
	
	<context:component-scan base-package="br.com.autmix.domain.dao.impl, br.com.autmix.domain.spi.impl, br.com.autmix.domain.aspect" />


This is my Manifest imports:

Import-Package: br.com.autmix.domain;version="[1.0.0,2.0.0)",
 br.com.autmix.domain.config;version="[1.0.0,2.0.0)",
 br.com.autmix.domain.config.backend;version="[1.0.0,2.0.0)",
 br.com.autmix.domain.dao;version="[1.0.0,1.0.0]",
 br.com.autmix.domain.dao.sistema;version="[1.0.0,2.0.0)",
 br.com.autmix.domain.dao.sistema.config.backend;version="[1.0.0,1.0.0]",
 br.com.autmix.domain.entidade;version="[1.0.0,2.0.0)",
 br.com.autmix.domain.exception;version="[1.0.0,2.0.0)",
 br.com.autmix.domain.logradouro;version="[1.0.0,2.0.0)",
 br.com.autmix.domain.sistema;version="[1.0.0,2.0.0)",
 br.com.autmix.domain.sistema.config.backend;version="[1.0.0,2.0.0)",
 br.com.autmix.domain.spi.security;version="[1.0.0,2.0.0)",
 javax.annotation;version="[1.1.0,1.1.0]",
 javax.persistence;jpa="2.0";version="[1.1.0,2.1.0)",
 javax.persistence.criteria;jpa="2.0";version="[1.1.0,2.1.0)",
 javax.persistence.metamodel;jpa="2.0";version="[1.1.0,2.1.0)",
 org.apache.commons.codec;version="[1.6.0,1.8.0)",
 org.apache.commons.codec.digest;version="[1.6.0,1.8.0)",
 org.apache.commons.lang3;version="[3.0.0,3.2.0)",
 org.aspectj.lang;version="[1.6.0,1.7.0)",
 org.aspectj.lang.annotation;version="[1.6.0,1.7.0)",
 org.aspectj.lang.reflect;version="[1.6.0,1.7.0)",
 org.aspectj.runtime;version="[1.6.0,1.7.0)",
 org.aspectj.runtime.reflect;version="[1.6.0,1.7.0)",
 org.aspectj.weaver;version="[1.6.0,1.7.0)",
 org.aspectj.weaver.ast;version="[1.6.0,1.7.0)",
 org.aspectj.weaver.bcel;version="[1.6.0,1.7.0)",
 org.aspectj.weaver.bcel.asm;version="[1.6.0,1.7.0)",
 org.aspectj.weaver.internal.tools;version="[1.6.0,1.7.0)",
 org.aspectj.weaver.loadtime;version="[1.6.0,1.7.0)",
 org.aspectj.weaver.loadtime.definition;version="[1.6.0,1.7.0)",
 org.aspectj.weaver.ltw;version="[1.6.0,1.7.0)",
 org.aspectj.weaver.model;version="[1.6.0,1.7.0)",
 org.aspectj.weaver.patterns;version="[1.6.0,1.7.0)",
 org.aspectj.weaver.reflect;version="[1.6.0,1.7.0)",
 org.aspectj.weaver.tools;version="[1.6.0,1.7.0)",
 org.osgi.framework;version="[1.7.0,1.7.0]",
 org.osgi.framework.hooks.weaving;version="[1.0.0,1.0.0]"


Detail: The class of the pointcut is a OSGI exported local Bean via <osgi:service...>

Thanks for any help!

[Updated on: Sat, 02 February 2013 09:59]

Report message to a moderator

Re: AspectJ Weaver error on @Aspect [message #1005068 is a reply to message #1004841] Thu, 24 January 2013 07:17 Go to previous messageGo to next message
Eduardo Frazão is currently offline Eduardo Frazão
Messages: 108
Registered: January 2012
Senior Member
Hi folks.. Doing more tests, I have some unexpected results.

First. Changing my aspect to:

@AfterThrowing(
			pointcut = "execution(* br.com.autmix.domain.spi.security.*.login(..))",
			throwing = "ex"
			)
	public void logarTentativaFalha(AuthenticationException ex) {


This works!

But if I put the complete Login Interface name, like that:

@AfterThrowing(
			pointcut = "execution(* br.com.autmix.domain.spi.security.LoginService.login(..))",
			throwing = "ex"
			)


Ive got this error:
Caused by: java.lang.IllegalArgumentException: warning no match for this type name: br.com.autmix.domain.spi.security.LoginService [Xlint:invalidAbsoluteTypeName]


If I create a @Pointcut on the aspect, and try to use it like that:

@Pointcut("execution(* br.com.autmix.domain.spi.security.*.login(..))")
	public void onLogin() {}
	
	@AfterThrowing(
			pointcut = "onLogin()",
			throwing = "ex"
			)
	public void logarTentativaFalha(AuthenticationException ex) {
		if(ex.getUsuario() != null) {
			System.out.println("Necessario logar isso, tem user aqui: " + ex.getUsuario().getLogin());
		} else {
			System.out.println("Tentativa de login falha sem usaurio presente");
		}
	}


I got this error:

Caused by: java.lang.IllegalArgumentException: warning can't determine implemented interfaces of missing type br.com.autmix.domain.aspect.log.LoginLoggerAspectImpl
 [Xlint:cantFindType]
	at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301)
	at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207)
	at org.springframework.aop.aspectj.AspectJExpressionPointcut.getFallbackPointcutExpression(AspectJExpressionPointcut.java:358)
	at org.springframework.aop.aspectj.AspectJExpressionPointcut.getShadowMatch(AspectJExpressionPointcut.java:409)
	at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:272)
	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:225)
	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:263)
	at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:295)
	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)



Declaring the pointcut explicit on the pointcut parameter of annotation works, but declaring it on a @Pointcut annotation, not.
If I use the complete name of Interface and the method to pointcut, it fails.

I appreciate any help! Thanks!!
Re: AspectJ Weaver error on @Aspect [message #1006827 is a reply to message #1005068] Sat, 02 February 2013 09:18 Go to previous messageGo to next message
Eduardo Frazão is currently offline Eduardo Frazão
Messages: 108
Registered: January 2012
Senior Member
Hi folks. Problem solved here.

Now, Im using with success AspectJ LTW and Spring AOP in some cases, with no problems, with Equinox Weaving hooks.

Im using Spring 3.1.0 with Virgo Tomcat 3.6.0.

This is what I have done:

Download this bundles:
org.eclipse.equinox.weaving.hook_1.0.200.I20120427-0800.jar
org.eclipse.equinox.weaving.aspectj_1.0.100.I20120427-0800.jar
org.eclipse.equinox.weaving.caching_1.0.100.I20120427-0800.jar

--
Virgo already contains the AspectJ Weaver. But, Ive downloaded the runtime too: (from Spring ebr)
com.springsource.org.aspectj.runtime-1.6.12.RELEASE.jar

Steps to configure:
Copy 
  org.eclipse.equinox.weaving.hook_1.0.200.I20120427-0800.jar
  com.springsource.org.aspectj.runtime-1.6.12.RELEASE.jar
  com.springsource.org.aspectj.weaver_1.6.12.RELEASE.jar
to plugins folder.

Copy 
  org.eclipse.equinox.weaving.aspectj_1.0.100.I20120427-0800.jar
  org.eclipse.equinox.weaving.caching_1.0.100.I20120427-0800.jar
to some repository



Edit config/org.eclipse.virgo.kernel.userregion.properties
   Add "file:plugins/org.eclipse.equinox.weaving.hook_1.0.200.I20120427-0800.jar" in "baseBundles". Do not set it to start, because this is a fragment bundle.
   Add "com.springsource.org.aspectj.weaver;bundle-version="0"" on "bundleImports"
   Add "org.eclipse.equinox.service.weaving;version="0"" on "packageImports"
   Add "repository:bundle/org.eclipse.equinox.weaving.aspectj" and "repository:bundle/org.eclipse.equinox.weaving.caching" on "initialArtifacts". This is because AspectJ Weaving service must be started before your application bundles.



Edit java6-server.profile
   Add "osgi.framework.extensions=org.eclipse.equinox.weaving.hook"


Now, some config in your bundles:
On your spring context:

<context:load-time-weaver aspectj-weaving="autodetect"/>
<context:spring-configured />


You must define an aop.xml file inside your META-INF folder.
This is an example:
<!DOCTYPE aspectj PUBLIC
        "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
	<weaver options="-verbose -debug">
		<include within="br.com.autmix.web.gui.aspect..*" />
	</weaver>
	<aspects>
		<aspect name="br.com.autmix.web.gui.aspect.i18n.I18NAspect" />
		<aspect name="br.com.autmix.web.gui.aspect.i18n.I18NVaadinAspect" />
	</aspects>
</aspectj>

Note that you must include your aspect to be woven too.

You need to change your MANIFEST too.

You can have aspects and classes to be matched with this aspects in the same bundle, and you can have aspects on another bundles.

If you dont need aspects from another bundles, you only must include this line in your MANIFEST.MF:

Require-Bundle: com.springsource.org.aspectj.weaver;visibility:="reexport"


If you want weave your classes with aspects in another bundle, you need to export the packages of this aspects on the host bundle, and on the target bundle, include this on your manifest:
Require-Bundle: your.aspect.bundle


Now, you can define your aop.xml on the target bundle, and reference the aspects of the host bundle in your aspects tag.

If you want to define Spring AOP Aspects, you can proceed as documented, but, does not use "<aop:aspectj-autoproxy />". This have cause problems here.
Insted, am using:

<aop:aspectj-autoproxy>
	<aop:include name="myAspectRefName"/>
</aop:aspectj-autoproxy>


I hope that this can help somebody!

Thanks!
Re: AspectJ Weaver error on @Aspect [message #1065441 is a reply to message #1006827] Tue, 25 June 2013 13:30 Go to previous messageGo to next message
Isaac Silva is currently offline Isaac Silva
Messages: 1
Registered: June 2013
Junior Member
Hi Eduardo!
Can you help me?

I create a spring+osgi project and i configure virgo tomcat as above. My aspect is registered but does not run.


>> Here is serviceability/logs/log.log
Found load-time weaver bean for bundle 'osgi-aspectj_0.0.1 [160]'. Switching to ServerLoadTimeWeaver
.....
Found AspectJ method: public void app1.ControllerInterceptor.invoke(org.aspectj.lang.JoinPoint)


>> app1.ControllerInterceptor.java
@Aspect
public class ControllerInterceptor {


	@Before("execution(* app1.web.controller.App1Controller.hello(..))")
	public void invoke(JoinPoint jp) {

		System.out.println("\nControllerInterceptor.invoke() is running!");

	}

}


>> app1.web.App1Controller.java
package app1.web.controller;

imports ...;

@Controller
public class App1Controller {


	@RequestMapping("/hello")
	public Hello hello(@RequestParam("name") String name) {

		return new Hello(name);
	}
}


>> WEB-INF/applicationContext.xml
        <context:annotation-config />
	<context:load-time-weaver aspectj-weaving="on" />
	<context:spring-configured />

	<bean id="myInterceptor" class="app1.ControllerInterceptor" />

	<aop:aspectj-autoproxy>
		<aop:include name="myInterceptor" />
	</aop:aspectj-autoproxy>

>> MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: osgi-aspectj
Bundle-SymbolicName: osgi-aspectj
Bundle-Version: 0.0.1
Bundle-Vendor: Iam.
Bundle-ClassPath: .,WEB-INF/classes
Web-ContextPath: osgi-aspectj
Import-Template: 
 org.springframework.*;version="[3.0,3.5)"
Import-Package: 
 javax.servlet;version="[2.5,3)",
 javax.servlet.http;version="[2.5,3)",
 org.aspectj.lang;version="[1.6,1.7)",
 org.aspectj.lang.annotation;version="[1.6,1.7)",
 net.sf.cglib.proxy;version="[2.1.3, 3.0.0)",
 net.sf.cglib.core;version="[2.1.3, 3.0.0)",
 org.springframework.core;version="[3.1, 3.5)",
 org.springframework.beans;version="[3.1, 3.5)",
 org.springframework.beans.factory;version="[3.1, 3.5)",
 org.springframework.beans.factory.config;version="[3.0, 3.5)",
 org.springframework.beans.factory.wiring;version="[3.0, 3.5)",
 org.springframework.beans.factory.annotation;version="[3.0, 3.5)",
 org.springframework.beans.factory.aspectj;version="[3.0, 3.5)", 
 org.springframework.scheduling.aspectj;version="[3.0, 3.5)",
 org.springframework.scheduling.annotation;version="[3.0, 3.5)",
 org.springframework.transaction.aspectj;version="[3.0, 3.5)",
 org.springframework.transaction.annotation;version="[3.0, 3.5)", 
 org.springframework.transaction.interceptor;version="[3.0, 3.5)", 
 org.springframework.cache.interceptor;version="[3.0, 3.5)",
 org.springframework.cache.annotation;version="[3.0, 3.5)", 
 org.springframework.cache.aspectj;version="[3.0, 3.5)",
 org.springframework.aop;version="[3.1, 3.5)",
 org.springframework.aop.framework;version="[3.1, 3.5)",
 org.springframework.stereotype;version="[3.0, 3.5)",
 org.springframework.context.weaving;version="[3.0, 3.5)",
 org.springframework.web.context;version="[3.1, 3.5)",
 org.springframework.context.config;version="[3.1, 3.5)",
 org.springframework.web.servlet;version="[3.1, 3.5)",
 org.springframework.web.servlet.config;version="[3.1, 3.5)",
 org.springframework.web.servlet.view;version="[3.1, 3.5)",
 freemarker.cache;version="[2.3.18,2.3.18]",
 org.eclipse.virgo.snaps.core;version="[3,4)",
 org.eclipse.virgo.web.dm;version="[2,4)"
Require-Bundle: 
 org.springframework.aspects,
 com.springsource.org.aspectj.weaver;visibility:="reexport"


The "hello" method of App1Controller is executing but my aspect "@Before..." does not is called.

Thanks for any help!
Re: AspectJ Weaver error on @Aspect [message #1070078 is a reply to message #1005068] Wed, 17 July 2013 03:51 Go to previous messageGo to next message
Felix Schöpf is currently offline Felix Schöpf
Messages: 4
Registered: February 2013
Junior Member
Eduardo Frazão wrote on Thu, 24 January 2013 07:17
Hi folks.. Doing more tests, I have some unexpected results.

First. Changing my aspect to:

@AfterThrowing(
			pointcut = "execution(* br.com.autmix.domain.spi.security.*.login(..))",
			throwing = "ex"
			)
	public void logarTentativaFalha(AuthenticationException ex) {


This works!

But if I put the complete Login Interface name, like that:

@AfterThrowing(
			pointcut = "execution(* br.com.autmix.domain.spi.security.LoginService.login(..))",
			throwing = "ex"
			)


Ive got this error:
Caused by: java.lang.IllegalArgumentException: warning no match for this type name: br.com.autmix.domain.spi.security.LoginService [Xlint:invalidAbsoluteTypeName]


If I create a @Pointcut on the aspect, and try to use it like that:

@Pointcut("execution(* br.com.autmix.domain.spi.security.*.login(..))")
	public void onLogin() {}
	
	@AfterThrowing(
			pointcut = "onLogin()",
			throwing = "ex"
			)
	public void logarTentativaFalha(AuthenticationException ex) {
		if(ex.getUsuario() != null) {
			System.out.println("Necessario logar isso, tem user aqui: " + ex.getUsuario().getLogin());
		} else {
			System.out.println("Tentativa de login falha sem usaurio presente");
		}
	}


I got this error:

Caused by: java.lang.IllegalArgumentException: warning can't determine implemented interfaces of missing type br.com.autmix.domain.aspect.log.LoginLoggerAspectImpl
 [Xlint:cantFindType]
	at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301)
	at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207)
	at org.springframework.aop.aspectj.AspectJExpressionPointcut.getFallbackPointcutExpression(AspectJExpressionPointcut.java:358)
	at org.springframework.aop.aspectj.AspectJExpressionPointcut.getShadowMatch(AspectJExpressionPointcut.java:409)
	at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:272)
	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:225)
	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:263)
	at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:295)
	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)



Declaring the pointcut explicit on the pointcut parameter of annotation works, but declaring it on a @Pointcut annotation, not.
If I use the complete name of Interface and the method to pointcut, it fails.

I appreciate any help! Thanks!!


I do get the exact same exceptions, but don't really want to use AspectJ, but pure Spring AOP instead and without CGLIB proxies. Do you have any hints on how this could be achieved - maybe with a slight adaptation of your solution?

Best regards - any help is very appreciated,
Felix
Re: AspectJ Weaver error on @Aspect [message #1070338 is a reply to message #1070078] Wed, 17 July 2013 15:19 Go to previous message
Florian Waibel is currently offline Florian Waibel
Messages: 51
Registered: June 2010
Member
Hello Felix,

if you have trouble with a fully quallified pointcut like
execution(* br.com.autmix.domain.spi.security.LoginService.login(..))


You may be able to work around this by narrowing down the pointcut using an additional pointcut designator this():

this(br.com.autmix.domain.spi.security.LoginService) and execution(* login(..))


Maybe you want to have a look at this Spring AOP example

Regards,
florian

[Updated on: Wed, 17 July 2013 15:33]

Report message to a moderator

Previous Topic:Where to download the virgo form tags sample?
Next Topic:AspectJ LTW on Virgo 3.6.2
Goto Forum:
  


Current Time: Tue Oct 08 02:31:50 EDT 2013

Powered by FUDForum. Page generated in 0.02031 seconds