Spring Data Cassandra: "No property findAll for type User"

cscan

I have a very simple spring data cassandra project for which the application context fails to startup. The entire project consists of four files: a domain object, a repository interface, the cassandra configuration, and an application entry point. Here is the domain object:

@Table
public class User {
    @PrimaryKeyColumn(name = "user_id", ordinal = 0, type = PrimaryKeyType.PARTITIONED)
    public UUID userId;
}

and the repository interface:

@Repository
public interface UserRepository extends PagingAndSortingRepository<User, UUID> {
}

The configuration is pretty simple:

@Configuration
public class TestSpringDataCassandraConfiguration extends AbstractCassandraConfiguration {
    @Override 
    protected String getKeyspaceName() {
        return "company";
    }
    @Override 
    protected List<CreateKeyspaceSpecification> getKeyspaceCreations() {
        return Collections.singletonList(CreateKeyspaceSpecification
                .createKeyspace(getKeyspaceName())
                .ifNotExists()
                .withSimpleReplication(1));
    }
    @Override 
    public String[] getEntityBasePackages() {
        return new String[] { "com.company.project.cassandra.entity"};
    }
    @Override 
    public SchemaAction getSchemaAction() {
        return SchemaAction.CREATE_IF_NOT_EXISTS;
    }
}

And the entry point is as simple as it can get.

@SpringBootApplication
public class TestApplication {
    public static void main(String[] sa) {
        SpringApplication.run(TestApplication.class, sa);
    }
}

Here are the project dependencies:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
        <version>1.5.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-cassandra</artifactId>
        <version>1.5.4.RELEASE</version>
    </dependency>
</dependencies>

Despite all of this, the application fails to start up with the following error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type User!
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:742) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at com.company.project.Application.main(Application.java:9) [classes/:na]
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type User!
        at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:247) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:398) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:378) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:86) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.cassandra.repository.query.PartTreeCassandraQuery.<init>(PartTreeCassandraQuery.java:47) ~[spring-data-cassandra-1.5.4.RELEASE.jar:na]
        at org.springframework.data.cassandra.repository.support.CassandraRepositoryFactory$CassandraQueryLookupStrategy.resolveQuery(CassandraRepositoryFactory.java:163) ~[spring-data-cassandra-1.5.4.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:436) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:221) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
        at org.springframework.data.cassandra.repository.support.CassandraRepositoryFactoryBean.afterPropertiesSet(CassandraRepositoryFactoryBean.java:76) ~[spring-data-cassandra-1.5.4.RELEASE.jar:na]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        ... 15 common frames omitted

The really weird thing is that the application starts up just fine if the UserRepository extends a CrudRepository. Does anyone have any idea what is wrong with this set up?

Jens Schauder

Making @mp911de's comment into a proper answer:

Spring Data for Apache Cassandra does not support PagingAndSortingRepository. Use just CrudRepository.

Unfortunately, the reference documentation mentions features as support for PagingAndSortingRepository but that is just the general part about how Spring Data works.

There are plans to work on an improvement of the documentation: https://jira.spring.io/browse/DATACMNS-1086

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Spring Data Cassandra and PreparedStatementCache

Spring Boot Data Embedded Cassandra

Spring data Cassandra, Allow filtering

Spring Data Cassandra LocalDateTime Conversion

Annotation for UDT by Spring data Cassandra

Spring Data Cassandra Counter update

Spring Data Cassandra and Map of Maps

spring-data-cassandra, Cassandra storing List<Integer> as field

How to use Testcontainers Cassandra with Spring Data for Apache Cassandra?

Create Spring.Data.Cassandra keyspace in runtime

spring cassandra data Version 2.1.4 pagination

spring-data-cassandra CassandraBatchTemplate is not public

How to create custom conversions for Spring Data Cassandra?

How to ignore an entity field in Spring Data Cassandra?

How to set Spring Data Cassandra keyspace dynamically?

spring boot data cassandra reactive JmxReporter problem

spring data cassandra reactive - custom delete method

spring-data-cassandra set consistency level

User Defined Type with spring-data-cassandra

How to use insert asynchronously into Cassandra with Spring Data?

spring-cassandra UDT data insert

Difference between codec and converters in Spring Data Cassandra?

Spring data Cassandra polymorphism, override column definition

NoSuchBeanDefinitionException: 'cassandraCluster' in spring data cassandra project

Custom Implementation of Repositories Spring-Data-Cassandra

Conflict between spring-data-cassandra and spring-data-solr

Weirdness ensues when running integraton tests with Spring Cloud Stream, Spring Data Cassandra and Cassandra-Unit-Spring

Spring boot application with spring data cassandra failing to start

Not able to connect to cassandra from spring boot aplication using spring-boot-starter-data-cassandra