1

My spring-boot/spring-data-cassandra application used to run well with Cassandra 2.1 but when I upgraded Cassandra to 3.3, it could not connect Cassandra server anymore. So in the pom file I decided to use a specific spring-data-cassandra module (1.3.2.RELEASE). I was hoping the new version of the spring-data-cassandra module will use the latest Cassandra Java driver. Though the new spring-data-cassandra module uses a newer version (2.1.5) of cassandra driver, it raised a weird exception when I ran the application:

[...CassandraConfig.class]; nested exception is java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.springframework.data.cassandra.repository.config.EnableCassandraRepositories.repositoryBaseClass()

Does anyone out there know why this exception is raised? The code worked fine with Cassandra 2.1/spring-data-cassandra 1.1.3.

Does spring-data-cassandra support Cassandra 3.3.0?

The source code of the CassandraConfig class is listed below:

@Configuration
@PropertySource(value={"classpath:/device/repo/cassandra.properties"})
@EnableCassandraRepositories("device.repo")
public class CassandraConfig {

@Autowired
private Environment env;

@Bean
public CassandraClusterFactoryBean cluster() {
    CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean();
    cluster.setContactPoints(getContactPoints());
    cluster.setPort(getPort());
    return cluster;
}

@Bean
public CassandraMappingContext mappingContext() {
    return new BasicCassandraMappingContext();
}

@Bean
public CassandraConverter converter() {
    return new MappingCassandraConverter(mappingContext());
}

@Bean
public CassandraSessionFactoryBean session() throws Exception {

    CassandraSessionFactoryBean session = new CassandraSessionFactoryBean();
    session.setCluster(cluster().getObject());
    session.setKeyspaceName(getKeyspaceName());
    session.setConverter(converter());
    session.setSchemaAction(SchemaAction.NONE);
    return session;
}   

@Bean
public CassandraOperations cassandraTemplate() throws Exception {
    return new CassandraTemplate(session().getObject());
}

protected String getKeyspaceName() {
    return env.getProperty("cassandra.keyspace");
}   


protected String getContactPoints() {
    return env.getProperty("cassandra.contactpoints");
}

protected int getPort() {
    return Integer.parseInt(env.getProperty("cassandra.port"));
}
}

Thanks so much!

matrix-li
  • 11
  • 2
  • Hi matrix-li, Spring Data Cassandra does not support Cassandra 3.x. I can't reproduce the `AnnotationFormatError` with the described dependencies. However, here's the link to a more detailed answer to the Spring Data Cassandra 3.3 question: http://stackoverflow.com/questions/34117374/com-datastax-driver-core-exceptions-invalidqueryexception-unconfigured-table-sc – mp911de Feb 18 '16 at 13:28
  • Thank you. It seems there is no simple way to use spring-data-cassandra with Cassandra 3.x. Replacing the embedded Cassandra java driver with the latest does't work at all. I will revert my Cassandra back to version 2.x for now but I do hope the spring-data-cassandra project will catch up. – matrix-li Feb 18 '16 at 14:15
  • The main issue is the Cassandra 3.x driver introduces a whole bunch of breaking changes to Spring Data Cassandra (see https://jira.spring.io/browse/DATACASS-169 and https://datastax-oss.atlassian.net/browse/JAVA-469). There's no ETA yet. – mp911de Feb 18 '16 at 14:25

0 Answers0