IllegalArgumentException Pointcut is not well formed expecting pattern

OR
Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting ‘name pattern’ at character position 41

Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'name pattern' at character position 41
execution(*com.javahonk.dao.IPersonDAO.*(..))
                                         ^

    at org.aspectj.weaver.tools.PointcutParser.resolvePointcutExpression(PointcutParser.java:316)
    at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:294)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:204)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:191)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:172)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)
    at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)
    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:1418)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    ... 11 more

 

If you are getting above exception when configure spring AOP means point cut is not well formed. Exception was happening due to no space between in expression shown in picture below:

honk

 

Full example fix code with space:

<aop:config>
    <aop:pointcut id="iPersonDAO" expression="execution(* com.javahonk.dao.IPersonDAO.*(..))"/>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="iPersonDAO"/>
</aop:config>

Leave a Reply

Your email address will not be published. Required fields are marked *