Hi,
I am trying to do AOP on Method which has custom Annotation
E.g
The Method Signature is as below.
@MyPermission(values=MyPermission.CREATE)
public String printHello(String data){
System.out.println("#$# Print Data "+data);
return "data "+" Invoked";
}
and I am trying to write Spring AOP using expression pointcut which get invoke before printHello.
..... XML AOP
<aop:aspect id="MyAspect" ref="myAOPHandler">
<aop:before method="printData"
pointcut="execution(java.lang.String com.test.practise..*Service.*(java.lang.String,..) ) and args(data,..) and @annotation(com.test.practise.annotations.MyPermis sion)" />
</aop:aspect>
I am receiving error as below while trying to deploy war application
Error Message:
BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAd visor#3': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdv isor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:405)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:728)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:380)
at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 45)
at weblogic.servlet.internal.EventsManager$FireContex tListenerAction.run(EventsManager.java:376)
at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Se curityManager.java:121)
....
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAd visor#3': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdv isor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
at org.springframework.beans.factory.support.Construc torResolver.autowireConstructor(ConstructorResolve r.java:254)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.autowireConstructor(Abs tractAutowireCapableBeanFactory.java:925)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:835)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.aop.framework.autoproxy.BeanFa ctoryAdvisorRetrievalHelper.findAdvisorBeans(BeanF actoryAdvisorRetrievalHelper.java:87)
at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.findCandidateAdvisors(Ab stractAdvisorAutoProxyCreator.java:98)
at org.springframework.aop.aspectj.autoproxy.AspectJA wareAdvisorAutoProxyCreator.shouldSkip(AspectJAwar eAdvisorAutoProxyCreator.java:105)
at org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.postProcessBeforeInstantiation( AbstractAutoProxyCreator.java:281)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyBeanPostProcessors BeforeInstantiation(AbstractAutowireCapableBeanFac tory.java:791)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.resolveBeforeInstantiat ion(AbstractAutowireCapableBeanFactory.java:762)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:399)
... 48 more
Caused by: org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdv isor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:115)
at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:87)
at org.springframework.beans.factory.support.Construc torResolver.autowireConstructor(ConstructorResolve r.java:248)
... 66 more
Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
at org.aspectj.weaver.tools.PointcutParser.parsePoint cutExpression(PointcutParser.java:317)
at org.springframework.aop.aspectj.AspectJExpressionP ointcut.buildPointcutExpression(AspectJExpressionP ointcut.java:206)
at org.springframework.aop.aspectj.AspectJExpressionP ointcut.checkReadyToMatch(AspectJExpressionPointcu t.java:193)
at org.springframework.aop.aspectj.AspectJExpressionP ointcut.getMethodMatcher(AspectJExpressionPointcut .java:179)
at org.springframework.aop.aspectj.AbstractAspectJAdv ice.buildSafePointcut(AbstractAspectJAdvice.java:1 89)
at org.springframework.aop.aspectj.AspectJPointcutAdv isor.<init>(AspectJPointcutAdvisor.java:51)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Construc tor.java:494)
at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:100)
... 68 more
Please help me on this..


Reply With Quote
