Hi there,
Its almost 8hrs I got a stuck with the @AfterThrowing aspect problem,
my enviornment is apsectj 1.5.3, asm 2.2, hibernate 3.2.0 and spring 2.0
This is my configuration file
<bean id="throwsAdvice" class="com.dpwn.newops.server.framework.intercepto r.exception.NewOpsAfterThrowsAdvise" />
<!-- Enable aspects -->
<aop:aspectj-autoproxy/>
<aop:config>
<aop:aspect id="afterThrowing" ref="throwsAdvice">
<aopointcut id="executionOfMethods"
expression="execution(* com..*.*(..))"/>
<aop:after-throwing
pointcut-ref="executionOfMethods"
throwing="ex"
method="afterThrowing"/>
</aop:aspect>
</aop:config>
and aspect code is
@Aspect
public class NewOpsAfterThrowsAdvise {
@AfterThrowing(pointcut="execution(* com.*.*(..))", throwing="ex")
public void afterThrowing(Throwable ex) {
............
}
}
The problem is that when i try to initialize the spring context, i get the following exception
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
h name 'org.springframework.aop.aspectj.AspectJPointcutAd visor': Cannot create i
nner bean '(inner bean)' while setting bean property 'advice'; nested exception
is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean
with name '(inner bean)': Invocation of init method failed; nested exception is
java.lang.IllegalStateException: Throwing argument name 'ex' was not bound in ad
vice arguments
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creati
ng bean with name '(inner bean)': Invocation of init method failed; nested excep
tion is java.lang.IllegalStateException: Throwing argument name 'ex' was not bou
nd in advice arguments
Caused by: java.lang.IllegalStateException: Throwing argument name 'ex' was not
bound in advice arguments
at org.springframework.aop.aspectj.AbstractAspectJAdv ice.bindExplicitArg
uments(AbstractAspectJAdvice.java:412)
at org.springframework.aop.aspectj.AbstractAspectJAdv ice.bindArgumentsBy
Name(AbstractAspectJAdvice.java:375)
at org.springframework.aop.aspectj.AbstractAspectJAdv ice.calculateArgume
ntBindings(AbstractAspectJAdvice.java:331)
at org.springframework.aop.aspectj.AbstractAspectJAdv ice.afterProperties
Set(AbstractAspectJAdvice.java:297)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableB eanFactory.java:1062)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBean Factory.java:1029)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFact ory.java:420)
at org.springframework.beans.factory.support.BeanDefi nitionValueResolver
.resolveInnerBeanDefinition(BeanDefinitionValueRes olver.java:198)
at org.springframework.beans.factory.support.BeanDefi nitionValueResolver
.resolveValueIfNecessary(BeanDefinitionValueResolv er.java:116)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapabl eBeanFactory.java:955)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFa ctory.java:729)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFact ory.java:416)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getOb
ject(AbstractBeanFactory.java:245)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:1 41)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
(AbstractBeanFactory.java:242)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
(AbstractBeanFactory.java:156)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactor y.java:290)
at org.springframework.context.support.AbstractApplic ationContext.refres
h(AbstractApplicationContext.java:348)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<i
nit>(ClassPathXmlApplicationContext.java:92)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<i
nit>(ClassPathXmlApplicationContext.java:77)
at com.dpwn.newops.integration.integrationtest.Server IntegrationApp.init
(ServerIntegrationApp.java:50)
at com.dpwn.newops.integration.integrationtest.Server IntegrationApp.main
(ServerIntegrationApp.java:34)
Exception in thread "main" java.lang.NullPointerException
at com.dpwn.newops.integration.integrationtest.Server IntegrationApp.init
(ServerIntegrationApp.java:61)
at com.dpwn.newops.integration.integrationtest.Server IntegrationApp.main
(ServerIntegrationApp.java:34)
I found similar queries in the forum and updated my Asm jar to 2.2 but still i get this exception.
any thoughts what Im doing wrong?
Thanks,
Ravi


ointcut id="executionOfMethods"
Reply With Quote
aspectj and annotation based aspectj <aop:aspectj-autoproxy/>. Remove one of the 2 don't mix. 