Announcement Announcement Module
Collapse
No announcement yet.
Problem using AOP with <tx:annotation-driven/> Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem using AOP with <tx:annotation-driven/>

    I am using Spring 2.5.6SEC01 with AspectJ 1.6.5. I have this config snippet:
    Code:
    <tx:annotation-driven/>
    <aop:aspectj-autoproxy proxy-target-class="true">
    		<aop:include name="loggingInterceptor" />
    	</aop:aspectj-autoproxy>
    <bean id="loggingInterceptor" class="xxx.LoggingInterceptor" />
    Here is my LoggingInterceptor:
    Code:
    @Aspect
    public class LoggingInterceptor {
    	private final Logger logger = LoggerFactory
    			.getLogger(LoggingInterceptor.class);
    
    	public LoggingInterceptor() {
    	}
    
    @Around("execution(* xxx..*.*(..))")
    	public Object profile(ProceedingJoinPoint pjp) throws Throwable {
    		long start = System.currentTimeMillis();
    		Object retVal = pjp.proceed();
    		logger.debug("Time spent in " + pjp.getClass() + pjp.getSignature()
    				+ (System.currentTimeMillis() - start));
    		return retVal;
    	}
    }
    I am running a Junit Test specifying my configuration file:
    Code:
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration (locations = { "classpath:/applicationContext.xml" })
    As the context is getting initialized an exception is thrown
    Here is the stacktrace
    Code:
    
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut 
    	at Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut 
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:87)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:98)
    	at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:83)
    	at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:105)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:356)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:325)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:361)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1344)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    	... 32 more
    Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut 
    	at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:302)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:206)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:193)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:174)
    	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:195)
    	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:250)
    	at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:284)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:113)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:85)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:66)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.getEarlyBeanReference(AbstractAutoProxyCreator.java:271)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getEarlyBeanReference(AbstractAutowireCapableBeanFactory.java:645)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$2.getObject(AbstractAutowireCapableBeanFactory.java:464)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:185)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:166)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:206)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
    Going through the code I see this is happening as org.springframework.transaction.annotation.Annotat ionTransactionAttributeSource#0 is being initialized.
    The exception is thrown in org.aspectj.weaver.patterns.Bindings in method checkAllBound(Iscope scope)
    Code:
    	public void checkAllBound(IScope scope) {
    		for (int i = 0, len = bindings.length; i < len; i++) {
    			if (bindings[i] == null) {
    				// ATAJ: avoid warnings for implicit bindings
    				if (scope.getFormal(i) instanceof FormalBinding.ImplicitFormalBinding) {
    					bindings[i] = new BindingTypePattern(scope.getFormal(i), false);
    				} else {
    					scope.message(IMessage.ERROR, scope.getFormal(i), "formal unbound in pointcut ");
    				}
    			}
    		}
    
    	}
    It appears that the bindings are not an instanceof FormalBinding.ImplicitFormalBinding.

    I am not sure if this is a configuration error or some incompatibility.

    Thanks for your help.
Working...
X