Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting ')'

caused by: java.lang.illegalargumentexception: error at ::0 formal unbound in pointcut
pointcut is not well-formed: expecting ')' at character position 16
caused by: java.lang.illegalargumentexception: warning no match for this type name:
spring aop passing parameters to advice
the pointcut expression
spring pointcut method with arguments
spring aop within
spring aop cheat sheet

The following is my aspect class. What i am trying to do is intercept all the lists which present in the Repository classes.

@Aspect
@Service
public class DecryptionAspect {

@AfterReturning(value="execution(java.util.List *(..)) " 
               + "&& target(com...repo..*Repository) "
                ,returning="list")
        public void decrypt(List list) throws Exception
        {
            //Do decryption here for the names inside the list
        }

    } 

For that purpose i have used the expression target(com...repo..*Repository). But it is throwing error.

Stack trace:

15:40:11,750 [main] -- ERROR Context initialization failed at org.springframework.web.context.ContextLoader 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerHandlerAdapter': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting ')' at character position 48
execution(java.util.List *(..)) && target(com...repo..*Repository) 
                                                ^^^^

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:452)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting ')' at character position 48
execution(java.util.List *(..)) && target(com...repo..*Repository) 
                                                ^^^^

    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
    at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:86)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:100)
    at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:84)
    at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:107)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:278)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:848)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:820)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:446)
    ... 25 more
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 java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting ')' at character position 48
execution(java.util.List *(..)) && target(com...repo..*Repository) 
                                                ^^^^

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    ... 42 more
Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting ')' at character position 48
execution(java.util.List *(..)) && target(com...repo..*Repository) 
                                                ^^^^

    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:195)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:181)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:162)
    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:1426)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    ... 48 more

Thanks in advance!


Try this:

@AfterReturning(value="execution(java.util.List *(..)) " +
"&& target(com..repo..*Repository) ",
returning="list")

Specifically; use com..repo instead of com...repo*

Edit: It is possible that you are not permitted to use wild cards inside a package name. None of the Spring point cut examples use a ".." wild card inside the package name. Try this:

@AfterReturning(value="execution(java.util.List *(..)) " +
"&& target(com.*.repo.*Repository) ",
returning="list")

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:  Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Initialization of bean failed; nested exception is


In a target() pointcut you cannot use a type pattern, you need to use a specific type, otherwise you cannot bind the matched type to a typed advice parameter, which is always an option that needs to work, even though you do not use it here. Look at this AspectJ cheat sheet. In the left column of page 2 you find:

target(Type | Var)

which means you can really just use a type or a binding variable name here. Besides, the AspectJ compiler would say: "wildcard type pattern not allowed, must use type name". However, if you use this pointcut

within(TypePat)

you can use a type pattern, which is what you are looking for. Thus, your solution would be something like

execution(java.util.List *(..)) && within(com..repo..*Repository)

or, even shorter because you already bind the return value to a List parameter, effectively limiting it to compatible return values already, also

execution(* *(..)) && within(com..repo..*Repository)

But actually I appreciate the "double safety net" approach above, because it will continue working even if you decide not to bind the result to a parameter anymore.

Pointcut is not well-formed: expecting '(' at character position 0 , resource [beans.xml]: Initialization of bean failed; nested exception is java.lang.​IllegalArgumentException: Pointcut is not well-formed: expecting '(' at character  This project is read only now. 3 Replies Latest reply on Nov 24, 2009 9:27 PM by chongkai . Initialization of bean failed - java.lang.UnsupportedOperationException


The expression which worked for me is below.

@AfterReturning(value="execution(* *..*Repository.*(..))",returning="list")
      public void decrypt(List list) throws Exception
        {
            //Do decryption here for the names inside the list
        }

    }

bean(nameOfBean) doesn't work with Spring Framework 5.0.1 on , IllegalArgumentException: Pointcut is not well-formed: expecting '(' at character position 0 Initialization of bean failed; nested exception is java.lang. PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Integer] for property 'mockBean.prop4'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [java.lang.Integer


Pointcut is not well-formed: expecting '(' at character position 0 mypt , Initialization of bean failed; nested exception is java.lang.​IllegalArgumentException: Pointcut is not well-formed: expecting ')' at character  This exception is thrown when Spring cannot load the class of the defined bean – this may occur if the Spring XML Configuration contains a bean that simply doesn't have a corresponding class.


pointcut 1 « AOP « Spring Q&A, BeanCreationException: Error creating bean with name AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.​lang.IllegalArgumentException: Pointcut is not well-formed: expecting '(' at character  MockitoPostProcessor can trigger early initialization of factory beans #21090 Closed mbhave modified the milestones: 2.2.x , 2.2.7 Apr 22, 2020


Spring AOP : Getting exception java.lang.IllegalArgumentException , Initialization of bean failed; nested exception is java.lang.​IllegalArgumentException: Pointcut is not well-formed: expecting 'name pattern' at​  Dismiss Join GitHub today. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.