Skip to main content


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] Thu, 24 January 2013 01:03 Go to next message
Eduardo Frazão is currently offline Eduardo FrazãoFriend
Messages: 123
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 14:59]

Report message to a moderator

Re: AspectJ Weaver error on @Aspect [message #1005068 is a reply to message #1004841] Thu, 24 January 2013 12:17 Go to previous messageGo to next message
Eduardo Frazão is currently offline Eduardo FrazãoFriend
Messages: 123
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 14:18 Go to previous messageGo to next message
Eduardo Frazão is currently offline Eduardo FrazãoFriend
Messages: 123
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 17:30 Go to previous messageGo to next message
Isaac Silva is currently offline Isaac SilvaFriend
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 07:51 Go to previous messageGo to next message
Felix Schöpf is currently offline Felix SchöpfFriend
Messages: 14
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 19:19 Go to previous messageGo to next message
Florian Waibel is currently offline Florian WaibelFriend
Messages: 166
Registered: June 2010
Senior 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 19:33]

Report message to a moderator

Re: AspectJ Weaver error on @Aspect [message #1209459 is a reply to message #1070338] Mon, 25 November 2013 14:26 Go to previous messageGo to next message
Felix Schöpf is currently offline Felix SchöpfFriend
Messages: 14
Registered: February 2013
Junior Member
Hi Florian,

after having solved my problem in a different way last time, I am back to aop.

If I use spring xml configuration, as in your example, everything is working as expected (with your hint to the this() designator). But, if I try to use annotation based aop configuration with @Aspect and @Before or @After and <aop:aspectj-autoproxy />, the annotated methods aren't called.
Maybe you could add another annotation based example to your GIT-repository or give a hint on why this isn't working or shouldn't work at all?

I'm using Virgo Tomcat 3.6.2 with Spring 3.2.3.

Best regards,
Felix
Re: AspectJ Weaver error on @Aspect [message #1213464 is a reply to message #1209459] Wed, 27 November 2013 08:48 Go to previous messageGo to next message
Florian Waibel is currently offline Florian WaibelFriend
Messages: 166
Registered: June 2010
Senior Member
Hi Felix,

I will try to put a sample together with annotation based AOP configuration.

You didn't explicitly mention that you added component scan, but I guess you already added this, right?

<context:component-scan base-package="put.your.package.here" />


Another thing I usually do when debugging this sort of things is increasing the log level of the related Spring classes.

Hope this helps,
florian
Re: AspectJ Weaver error on @Aspect [message #1213618 is a reply to message #1213464] Wed, 27 November 2013 10:12 Go to previous messageGo to next message
Felix Schöpf is currently offline Felix SchöpfFriend
Messages: 14
Registered: February 2013
Junior Member
Hi Florian,

Yes, for sure I added the component scan.

Increasing the log level of related Spring classes - how would you do that?

Best regards,
Felix
Re: AspectJ Weaver error on @Aspect [message #1213767 is a reply to message #1213618] Wed, 27 November 2013 11:37 Go to previous messageGo to next message
Florian Waibel is currently offline Florian WaibelFriend
Messages: 166
Registered: June 2010
Senior Member
Hi Felix,

in preparation for the annotation based sample I just stumbled across a note in the Spring documentation:

Autodetecting aspects through component scanning

You may register aspect classes as regular beans in your Spring XML configuration, or autodetect them throuch classpath scanning - just like any other Spring-managed bean. However, note that the @Aspect annotation is not sufficient for autodetection in the classpath: For that purpose, you need to add a separate @Component annotation (or alternatively a custom stereotype annotation that qualifies, as per the rules of Spring's component scanner).


Did you add the @Component annotation to your @Aspect annotated class? I think this is something easily missed.

Regards,
florian
Re: AspectJ Weaver error on @Aspect [message #1213794 is a reply to message #1213767] Wed, 27 November 2013 11:55 Go to previous messageGo to next message
Florian Waibel is currently offline Florian WaibelFriend
Messages: 166
Registered: June 2010
Senior Member
Regarding the logging: The easiest way is to modify the serviceability.xml of Virgo itself if you do not have a log configuration in your application. Simply add something like:

<logger level="DEBUG" additivity="false" name="org.springframework">
    <appender-ref ref="SIFTED_LOG_FILE" />
    <appender-ref ref="LOG_FILE" />
</logger>


Then you should be able to observe whether the ClassPathBeanDefinitionScanner kicks in for example:

2013-11-27 12:44:42.641] DEBUG start-signalling-1           o.s.context.annotation.ClassPathBeanDefinitionScanner             Identified candidate component class: file [/tools/virgo-tomcat-server-3.6.2.RELEASE/work/deployer/s/global/46/0/sample.homepage.jar/sample/homepage/HomepageController.class]

[Updated on: Wed, 27 November 2013 11:55]

Report message to a moderator

Re: AspectJ Weaver error on @Aspect [message #1226661 is a reply to message #1213794] Thu, 02 January 2014 10:41 Go to previous message
Eduardo Frazão is currently offline Eduardo FrazãoFriend
Messages: 123
Registered: January 2012
Senior Member
Hi Folks! Last week I try to use @Configurable with AspectJ LTW. The aspect works well, but I have a problem with the Spring Context used to resolve the bean.

I have a Web Bundle (WAB), and several other bundles. When I instantiate a object from another bundle, by a requisition done in the Web Application, Spring uses the context from the WAB bundle to resolve the bean dependencies, and not the context of the Bean itself. I think that Spring lookup the context using a thread context class loader, thread local references, or something like that.

I'm thinking to build my own aspect, to resolve this issue somehow (hold a context reference by each class classloader).
For now, I'm processing the bean depedencies by a static call on constructor, that asks spring to do the work.

What you guys think about it?
Previous Topic:Virgo bundle hold on too much memory
Next Topic:Par/plan Scoping issue
Goto Forum:
  


Current Time: Thu Apr 25 16:52:00 GMT 2024

Powered by FUDForum. Page generated in 0.03655 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top