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.

  • POJO: --------- @Table(value="emp") public class Employee implements Serializable{ @PrimaryKey @Column(value="emp_id") private Integer id; @Column(value="emp_name") private String name; @Column(value="emp_city") private String city; @Column(value="emp_phone") private BigInteger phoneNumber; @Column(value="emp_sal") private BigInteger salary; //simple setter & getter methods. } Repository : ---------------- public interface EmployeeRepository extends CassandraRepository<Employee> { } spring-contect-config.xml: ---------------------------------- <!-- REQUIRED: The Cassandra Cluster --> <cassandra:cluster id="cluster" contact-points="127.0.0.1" port="9042" /> <!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching to a keyspace --> <cassandra:session id="session" keyspace-name="da_name" cluster-ref="cluster"/> <!-- REQUIRED: The Default Cassandra Mapping Context used by CassandraConverter --> <cassandra:mapping /> <!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate --> <cassandra:converter /> <!-- REQUIRED: The Cassandra Template is the building block of all Spring Data Cassandra --> <cassandra:template id="cassandraTemplate" session-ref="session" /> <!-- OPTIONAL: If you are using Spring Data Cassandra Repositories, add your base packages to scan here --> <cassandra:mapping entity-base-packages="com.xxx.cassandra.pojo" /> <cassandra:repositories base-package="com.xxx.cassandra.repo" /> *When i runs the code,which throws an error message saying like :* Here is the link: --------------------- http://stackoverflow.com/questions/26710114/cannot-resolve-reference-to-bean-cqltemplate-while-setting-bean-property-cass Here is the stacktrace: ------------------------------ Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeRepository': Cannot resolve reference to bean 'cqlTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cqlTemplate' is defined at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1222) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at com.purpletalk.cassandra.App.main(App.java:26) Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cqlTemplate' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1168) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ... 15 more
    via by Govardhan Rao Ganji,
  • POJO: --------- @Table(value="emp") public class Employee implements Serializable{ @PrimaryKey @Column(value="emp_id") private Integer id; @Column(value="emp_name") private String name; @Column(value="emp_city") private String city; @Column(value="emp_phone") private BigInteger phoneNumber; @Column(value="emp_sal") private BigInteger salary; //simple setter & getter methods. } Repository : ---------------- public interface EmployeeRepository extends CassandraRepository<Employee> { } spring-contect-config.xml: ---------------------------------- <!-- REQUIRED: The Cassandra Cluster --> <cassandra:cluster id="cluster" contact-points="127.0.0.1" port="9042" /> <!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching to a keyspace --> <cassandra:session id="session" keyspace-name="da_name" cluster-ref="cluster"/> <!-- REQUIRED: The Default Cassandra Mapping Context used by CassandraConverter --> <cassandra:mapping /> <!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate --> <cassandra:converter /> <!-- REQUIRED: The Cassandra Template is the building block of all Spring Data Cassandra --> <cassandra:template id="cassandraTemplate" session-ref="session" /> <!-- OPTIONAL: If you are using Spring Data Cassandra Repositories, add your base packages to scan here --> <cassandra:mapping entity-base-packages="com.xxx.cassandra.pojo" /> <cassandra:repositories base-package="com.xxx.cassandra.repo" /> *When i runs the code,which throws an error message saying like :* Here is the link: --------------------- http://stackoverflow.com/questions/26710114/cannot-resolve-reference-to-bean-cqltemplate-while-setting-bean-property-cass Here is the stacktrace: ------------------------------ Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeRepository': Cannot resolve reference to bean 'cqlTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cqlTemplate' is defined at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1222) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at com.purpletalk.cassandra.App.main(App.java:26) Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cqlTemplate' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1168) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ... 15 more
    via by Govardhan Rao Ganji,
  • Hi, I believe I found an issue with autowiring and generics. I attached a simple eclipse example project to show you the issue. Here is my "application-context.xml" file: {code:xml|title=application-context.xml|borderStyle=solid} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <context:annotation-config/> <bean class="spring.test.generics.GenericInterface1Impl" factory-method="create"/> <bean class="spring.test.generics.GenericInterface2Impl"/> </beans> {code} I have 2 classes: "GenericInterface1Impl" and "GenericInterface2Impl". "GenericInterface1Impl" depends on an implementation of "GenericInterface2". {code:title=GenericInterface1Impl.java|borderStyle=solid} public class GenericInterface1Impl<T> implements GenericInterface1<T>{ @Autowired private GenericInterface2<T> gi2; @Override public String doSomethingGeneric(T o) { return gi2.doSomethingMoreGeneric(o) + "_somethingGeneric_" + o; } /** * Factory Method * @return an instance of <code>GenericInterface1<String></code> */ public static GenericInterface1<String> create(){ return new GenericInterface1Impl<>(); } } {code} {code:title=GenericInterface2Impl.java|borderStyle=solid} public class GenericInterface2Impl implements GenericInterface2<String>{ @Override public String doSomethingMoreGeneric(String o) { return "somethingMoreGeneric_" + o; } } {code} "GenericInterface1Impl" has a factory method that creates an instance of "GenericInterface1<String>". The issue is: spring can't find a qualifying bean for the attribute "GenericInterface1.gi2" even though there's a suitable "GenericInterface2<String>" implementation (GenericInterface2Impl) in the application context. The exact same code works perfectly with spring version 3.2.8 but fails with spring version 4.0.2. You can easily change the spring version to 3.2.8 in "pom.xml" to verify that. Here's the exception stack trace: {noformat} Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.test.generics.GenericInterface1Impl#0': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics.GenericInterface2 spring.test.generics.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at spring.test.generics.App.main(App.java:13) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics.GenericInterface2 spring.test.generics.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ... 13 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1100) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) ... 15 more {noformat} Thanks, Jair Jr
    via by Jair da Silva Ferreira Júnior,
    • org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeRepository': Cannot resolve reference to bean 'cqlTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cqlTemplate' is defined at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1222) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at com.purpletalk.cassandra.App.main(App.java:26) Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cqlTemplate' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1168) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ... 15 more

    Users with the same issue

    Victor_IT
    6 times, last one,
    Dunmer
    4 times, last one,
    batwalrus76
    3 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    188 more bugmates