Uploaded image for project: 'Spring Data for Apache Cassandra'
  1. Spring Data for Apache Cassandra
  2. DATACASS-228

Simple CassandraRepository implementation is not working

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Works as Designed
    • Affects Version/s: 1.4.6 (Hopper SR6), 1.5 RC1 (Ingalls)
    • Fix Version/s: None
    • Component/s: Configuration, Core
    • Labels:
    • Last commented by a User:
      true
    • Sprint:
      Ingalls GA

      Description

      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-context-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
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mp911de Mark Paluch
              Reporter:
              vardhan4vm Govardhana Rao Ganji
              Last updater:
              Mark Paluch
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 45 weeks, 2 days ago