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.

  • Autowiring of a prototype scoped bean into an ObjectFactory now fails with 3.1.1, however it works on 3.0.x & 3.1.0. For example we something like: {code} @Component @Scope("prototype") public class SomePrototypeBean { } @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({ "/test-context.xml" }) public class SomeTest { @Autowired ObjectFactory<SomePrototypeBean> prototypeBeanFactory; @Test public void test() { SomePrototypeBean b = prototypeBeanFactory.getObject(); assertNotNull(b); } } {code} Below is a real stack from our unit tests: {noformat} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'statelessZoneDAOImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.beans.factory.ObjectFactory biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory; nested exception is java.lang.IllegalArgumentException: Can not set org.springframework.beans.factory.ObjectFactory field biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory to biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneRestrictIpDAOImpl at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106) 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.doGetBean(AbstractBeanFactory.java:313) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790) at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectFactory.getObject(DefaultListableBeanFactory.java:1010) at biz.neustar.ultra.model.persistence.DbWriterImpl.writeVersionedStyle(DbWriterImpl.java:169) at biz.neustar.ultra.model.persistence.ChunkOperationsImplTest.blowChunks(ChunkOperationsImplTest.java:83) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.beans.factory.ObjectFactory biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory; nested exception is java.lang.IllegalArgumentException: Can not set org.springframework.beans.factory.ObjectFactory field biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory to biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneRestrictIpDAOImpl at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284) Caused by: java.lang.IllegalArgumentException: Can not set org.springframework.beans.factory.ObjectFactory field biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory to biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneRestrictIpDAOImpl at java.lang.reflect.Field.set(Field.java:657) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502) {noformat}
    via by Jeffrey Damick,
  • Autowiring of a prototype scoped bean into an ObjectFactory now fails with 3.1.1, however it works on 3.0.x & 3.1.0. For example we something like: {code} @Component @Scope("prototype") public class SomePrototypeBean { } @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({ "/test-context.xml" }) public class SomeTest { @Autowired ObjectFactory<SomePrototypeBean> prototypeBeanFactory; @Test public void test() { SomePrototypeBean b = prototypeBeanFactory.getObject(); assertNotNull(b); } } {code} Below is a real stack from our unit tests: {noformat} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'statelessZoneDAOImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.beans.factory.ObjectFactory biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory; nested exception is java.lang.IllegalArgumentException: Can not set org.springframework.beans.factory.ObjectFactory field biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory to biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneRestrictIpDAOImpl at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106) 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.doGetBean(AbstractBeanFactory.java:313) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790) at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectFactory.getObject(DefaultListableBeanFactory.java:1010) at biz.neustar.ultra.model.persistence.DbWriterImpl.writeVersionedStyle(DbWriterImpl.java:169) at biz.neustar.ultra.model.persistence.ChunkOperationsImplTest.blowChunks(ChunkOperationsImplTest.java:83) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.beans.factory.ObjectFactory biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory; nested exception is java.lang.IllegalArgumentException: Can not set org.springframework.beans.factory.ObjectFactory field biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory to biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneRestrictIpDAOImpl at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284) Caused by: java.lang.IllegalArgumentException: Can not set org.springframework.beans.factory.ObjectFactory field biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory to biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneRestrictIpDAOImpl at java.lang.reflect.Field.set(Field.java:657) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502) {noformat}
    via by Jeffrey Damick,
  • Problemas com upload
    via by diogo.capistrano,
  • How to inject EntityManager in CDI (weld)?
    via Stack Overflow by SuperChia
    ,
    • org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'statelessZoneDAOImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.beans.factory.ObjectFactory biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory; nested exception is java.lang.IllegalArgumentException: Can not set org.springframework.beans.factory.ObjectFactory field biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory to biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneRestrictIpDAOImpl at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106) 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.doGetBean(AbstractBeanFactory.java:313) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790) at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectFactory.getObject(DefaultListableBeanFactory.java:1010) at biz.neustar.ultra.model.persistence.DbWriterImpl.writeVersionedStyle(DbWriterImpl.java:169) at biz.neustar.ultra.model.persistence.ChunkOperationsImplTest.blowChunks(ChunkOperationsImplTest.java:83) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.beans.factory.ObjectFactory biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory; nested exception is java.lang.IllegalArgumentException: Can not set org.springframework.beans.factory.ObjectFactory field biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory to biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneRestrictIpDAOImpl at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284) Caused by: java.lang.IllegalArgumentException: Can not set org.springframework.beans.factory.ObjectFactory field biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneDAOImpl.zriDAOFactory to biz.neustar.ultra.model.rdb.dao.hibernate.stateless.ZoneRestrictIpDAOImpl at java.lang.reflect.Field.set(Field.java:657) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Andreas HäberAndreas Häber
    5 times, last one,
    linxiaolonglinxiaolong
    8 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    filpgamefilpgame
    20 times, last one,
    37 more bugmates