Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple CassandraRepository implementation is not working [DATACASS-228] #400

Closed
spring-projects-issues opened this issue Jul 27, 2015 · 2 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jul 27, 2015

Govardhana Rao Ganji opened DATACASS-228 and commented

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

Affects: 1.4.6 (Hopper SR6), 1.5 RC1 (Ingalls)

Issue Links:

  • DATACASS-387 Remove default bean creation when using XML configuration

1 votes, 3 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 17, 2017

Mark Paluch commented

Our namespace support defaults to cqlTemplate for <cassandra:repositories cassandra-template-ref=… />. That default is in place for quite a while and changing the default would probably break existing code therefore moving the fix to Spring Data Cassandra 2.0

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 25, 2017

Mark Paluch commented

For now, set <cassandra:repositories cassandra-template-ref="cassandraTemplate" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants