Hi all

I had the problem of adding aspects to non spring-managed objects. For this reason I've resorted to AspectJProxyFactory and it works like a charm.

Now, the aspect I needed to apply is one that adds transaction demarcation to these objects; since I don't personally like the @Transactional approach I'd understood that I needed to subclass AbstractTransactionAspect.

My question lies here: to avoid having to compile .aj aspects I had thought of extending AbstractTransactionAspect with an @Aspect thus resulting in something like

Code:

@Aspect
public class TransactionAspect2 extends AbstractTransactionAspect {

    protected TransactionAspect2() {
        super(null);
    }

    @Pointcut("execution(* org.atalaya.isec.update.RemoteUpdateThread.*(..))")
    protected void transactionalMethodExecution() {
    }   
}
Nevertheless when trying to pass this aspect to the proxy factory I get

Code:
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.atalaya.isec.aop.update.UpdateAspect]: Constructor threw exception; nested exception is java.lang.IllegalStateException: Expecting to find 2 arguments to bind by name in advice, but actually found 1 arguments.
Caused by: java.lang.IllegalStateException: Expecting to find 2 arguments to bind by name in advice, but actually found 1 arguments.
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.bindExplicitArguments(AbstractAspectJAdvice.java:412)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.bindArgumentsByName(AbstractAspectJAdvice.java:377)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.calculateArgumentBindings(AbstractAspectJAdvice.java:344)
	at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.getAdvice(ReflectiveAspectJAdvisorFactory.java:219)
	at org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl.instantiateAdvice(InstantiationModelAwarePointcutAdvisorImpl.java:145)
	at org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl.<init>(InstantiationModelAwarePointcutAdvisorImpl.java:94)
	at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.getAdvisor(ReflectiveAspectJAdvisorFactory.java:135)
	at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory$1.doWith(ReflectiveAspectJAdvisorFactory.java:75)
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:226)
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:203)
	at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.getAdvisors(ReflectiveAspectJAdvisorFactory.java:71)
	at org.springframework.aop.aspectj.annotation.AspectJProxyFactory.addAdvisorsFromAspectInstanceFactory(AspectJProxyFactory.java:117)
	at org.springframework.aop.aspectj.annotation.AspectJProxyFactory.addAspect(AspectJProxyFactory.java:95)
Actually a simple workaround has been to rewrite AbstractTransactionAspect as an @Aspect and the same setup works fine. I still don't know if what I've accomplished makes any sense generally speaking. And actually I don't have an explanation of why it's not legal to extend an aspect with an @Aspect...

Thanks a lot for any comment
Francesco