Announcement Announcement Module
Collapse
No announcement yet.
ClassCastException with AfterThrowing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ClassCastException with AfterThrowing

    Hello,

    I want to handle exceptions with AOP. I have a problem with the pointcut in AfterThrowing.

    @AfterThrowing(pointcut = "execution(* de.tester.vdbo.bo.*.*(..))", throwing = "e")
    public void handleException(JoinPoint joinPoint, Throwable e) throws Exception {
    log.debug("!!!throw exception!!!");
    }


    I get the following Stacktrace while deploying on Websphere:

    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)#2': Initialization of bean failed; nested exception is java.lang.ClassCastException: org.aspectj.weaver.ResolvedType$Array incompatible with org.aspectj.weaver.ReferenceType
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveInnerBean(BeanDefinitio nValueResolver.java:270)
    ... 90 more
    Caused by: java.lang.ClassCastException: org.aspectj.weaver.ResolvedType$Array incompatible with org.aspectj.weaver.ReferenceType
    at org.aspectj.weaver.BoundedReferenceType.parameteri ze(BoundedReferenceType.java:64)
    at org.aspectj.weaver.ResolvedType.parameterize(Resol vedType.java:1878)
    at org.aspectj.weaver.ResolvedMemberImpl.parameterize (ResolvedMemberImpl.java:682)
    at org.aspectj.weaver.ResolvedMemberImpl.parameterize dWith(ResolvedMemberImpl.java:644)
    at org.aspectj.weaver.ResolvedMemberImpl.parameterize dWith(ResolvedMemberImpl.java:597)
    at org.aspectj.weaver.ReferenceType.getDeclaredMethod s(ReferenceType.java:512)
    at org.aspectj.weaver.ResolvedType.addAndRecurse(Reso lvedType.java:263)
    at org.aspectj.weaver.ResolvedType.getMethodsWithoutI terator(ResolvedType.java:258)
    at org.aspectj.weaver.ResolvedType.lookupResolvedMemb er(ResolvedType.java:379)
    at org.aspectj.weaver.JoinPointSignatureIterator.find SignaturesFromSupertypes(JoinPointSignatureIterato r.java:178)
    at org.aspectj.weaver.JoinPointSignatureIterator.hasN ext(JoinPointSignatureIterator.java:69)
    at org.aspectj.weaver.patterns.SignaturePattern.match es(SignaturePattern.java:287)
    at org.aspectj.weaver.patterns.KindedPointcut.matchIn ternal(KindedPointcut.java:106)
    at org.aspectj.weaver.patterns.Pointcut.match(Pointcu t.java:146)
    at org.aspectj.weaver.internal.tools.PointcutExpressi onImpl.getShadowMatch(PointcutExpressionImpl.java: 235)
    at org.aspectj.weaver.internal.tools.PointcutExpressi onImpl.matchesExecution(PointcutExpressionImpl.jav a:101)
    at org.aspectj.weaver.internal.tools.PointcutExpressi onImpl.matchesMethodExecution(PointcutExpressionIm pl.java:92)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.getShadowMatch(AspectJExpressionPointcut.j ava:403)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.matches(AspectJExpressionPointcut.java:272 )
    at org.springframework.aop.support.AopUtils.canApply( AopUtils.java:226)
    at org.springframework.aop.support.AopUtils.canApply( AopUtils.java:264)
    at org.springframework.aop.support.AopUtils.findAdvis orsThatCanApply(AopUtils.java:296)
    at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.findAdvisorsThatCanApply (AbstractAdvisorAutoProxyCreator.java:117)
    at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.findEligibleAdvisors(Abs tractAdvisorAutoProxyCreator.java:87)
    at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.getAdvicesAndAdvisorsFor Bean(AbstractAdvisorAutoProxyCreator.java:68)
    at org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.wrapIfNecessary(AbstractAutoPro xyCreator.java:359)
    at org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.postProcessAfterInitialization( AbstractAutoProxyCreator.java:322)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyBeanPostProcessors AfterInitialization(AbstractAutowireCapableBeanFac tory.java:407)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1461)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:519)
    ... 92 more

    if I write the concrete method as Pointcut it works, e.g.
    @AfterThrowing(pointcut = "execution(* de.tester.vdbo.bo.Test.test(..))", throwing = "e")

    I use Spring 3.1.2 with AspectJ 1.5.3

    Thanks for help
Working...
X