org.springframework.beans.factory.BeanCreationException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I have a simple annotation: {code} @Retention(RetentionPolicy.RUNTIME) @Target([ElementType.TYPE, ElementType.METHOD]) public @interface Tx { String value() default ''; } {code} which I can apply either on a method or class level (which would then mean it applies to all methods). In my aspect, I have the following pointcut and advice: {code} @Pointcut('within(test.service..*) && !execution(* getMetaClass())') void serviceMethods() {} @Around(value = 'serviceMethods() && (@annotation(txmethod) || @target(txclass))', argNames = 'txmethod, txclass') Object aroundService_inconsistentBinding(ProceedingJoinPoint pjp, Tx txmethod, Tx txclass) { println ">>> before $pjp.signature.name with '${txValue(txmethod, txclass)}'" pjp.proceed() } private String txValue(Tx txmethod, Tx txclass) { txmethod ? txmethod.value() : txclass.value() } {code} and a simple usage class: {code} //@Tx('class') class PersonService { @Tx('method') void method() { } } {code} This fails at runtime with the following exception: {quote} Caught: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personService' defined in class path resource [beans.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 inconsistent binding org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personService' defined in class path resource [beans.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 inconsistent binding at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:532) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at Main.run(Main.groovy:5) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Caused by: java.lang.IllegalArgumentException: error at ::0 inconsistent binding at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301) at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:208) at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:194) at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:183) at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:164) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:208) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:262) at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:294) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:118) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:88) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:69) 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:412) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1492) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) ... 12 more {quote} Why is the binding inconsistent? So, I tried to replace the advice with the following: {code} @Around('serviceMethods() && (@annotation(tx) || @target(tx))') Object aroundService_alwaysClassLevelUsed(ProceedingJoinPoint pjp, Tx tx) { println ">>> before '$pjp.signature' with '${tx.value()}'" pjp.proceed() } {code} Now, I get a NPE: {quote} Caught: java.lang.NullPointerException: Cannot invoke method value() on null object java.lang.NullPointerException: Cannot invoke method value() on null object at test.aop.MyAspect.aroundService_alwaysClassLevelUsed(MyAspect.groovy:24) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610) at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631) at test.service.PersonService$$EnhancerByCGLIB$$aa5c5d10.method(<generated>) at test.service.PersonService$method.call(Unknown Source) at Main.run(Main.groovy:8) {quote} The problem is that the binding expression is not short-circuit, i.e., the annotation on the method is found, but spring (or is it aspectj?) binds further and bind a null Tx annotation on the class level to the parameter. This can be easily checked when the PersonService class has both class-level and method-level annotations configured. I attach a groovy-2.1.0 and gradle-1.4 based project to help easily reproduce this issue. Just invoke {code:none} ./gradlew clean run {code} in the project folder. I also configured remote debugging so, but it doesn't suspend the JVM - change line 78 of build.gradle accordingly.
    via by Wujek,
  • I have a simple annotation: {code} @Retention(RetentionPolicy.RUNTIME) @Target([ElementType.TYPE, ElementType.METHOD]) public @interface Tx { String value() default ''; } {code} which I can apply either on a method or class level (which would then mean it applies to all methods). In my aspect, I have the following pointcut and advice: {code} @Pointcut('within(test.service..*) && !execution(* getMetaClass())') void serviceMethods() {} @Around(value = 'serviceMethods() && (@annotation(txmethod) || @target(txclass))', argNames = 'txmethod, txclass') Object aroundService_inconsistentBinding(ProceedingJoinPoint pjp, Tx txmethod, Tx txclass) { println ">>> before $pjp.signature.name with '${txValue(txmethod, txclass)}'" pjp.proceed() } private String txValue(Tx txmethod, Tx txclass) { txmethod ? txmethod.value() : txclass.value() } {code} and a simple usage class: {code} //@Tx('class') class PersonService { @Tx('method') void method() { } } {code} This fails at runtime with the following exception: {quote} Caught: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personService' defined in class path resource [beans.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 inconsistent binding org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personService' defined in class path resource [beans.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 inconsistent binding at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:532) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at Main.run(Main.groovy:5) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Caused by: java.lang.IllegalArgumentException: error at ::0 inconsistent binding at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301) at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:208) at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:194) at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:183) at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:164) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:208) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:262) at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:294) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:118) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:88) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:69) 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:412) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1492) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) ... 12 more {quote} Why is the binding inconsistent? So, I tried to replace the advice with the following: {code} @Around('serviceMethods() && (@annotation(tx) || @target(tx))') Object aroundService_alwaysClassLevelUsed(ProceedingJoinPoint pjp, Tx tx) { println ">>> before '$pjp.signature' with '${tx.value()}'" pjp.proceed() } {code} Now, I get a NPE: {quote} Caught: java.lang.NullPointerException: Cannot invoke method value() on null object java.lang.NullPointerException: Cannot invoke method value() on null object at test.aop.MyAspect.aroundService_alwaysClassLevelUsed(MyAspect.groovy:24) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610) at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631) at test.service.PersonService$$EnhancerByCGLIB$$aa5c5d10.method(<generated>) at test.service.PersonService$method.call(Unknown Source) at Main.run(Main.groovy:8) {quote} The problem is that the binding expression is not short-circuit, i.e., the annotation on the method is found, but spring (or is it aspectj?) binds further and bind a null Tx annotation on the class level to the parameter. This can be easily checked when the PersonService class has both class-level and method-level annotations configured. I attach a groovy-2.1.0 and gradle-1.4 based project to help easily reproduce this issue. Just invoke {code:none} ./gradlew clean run {code} in the project folder. I also configured remote debugging so, but it doesn't suspend the JVM - change line 78 of build.gradle accordingly.
    via by Wujek,
  • Spring AOP
    via by meruva surendra,
  • OpenNMS / Mailing Lists
    via by Unknown author,
  • Spring Aop Error of formal unbound pointcut
    via Stack Overflow by duke
    ,
  • SPRING AOP: error at ::0 can't find referenced pointcut
    via by Alessandro Minutello,
    • org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personService' defined in class path resource [beans.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 inconsistent binding at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:532) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at Main.run(Main.groovy:5) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Caused by: java.lang.IllegalArgumentException: error at ::0 inconsistent binding at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301) at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:208) at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:194) at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:183) at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:164) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:208) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:262) at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:294) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:118) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:88) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:69) 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:412) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1492) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) ... 12 more

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor2 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    23 more bugmates