1

I am trying few proof of concepts to test it for time series data. I took the sample from spring website and configured it on eclipse.

Below are few details:

Cassandra Version** - 3.0.9 Spring data cassandra version - 1.0.0.RELEASE DataStax java driver core- cassandra-driver-core-3.1.2

I am executing the below code:

Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9042).build();
          Session session = cluster.connect("axiaglobal");
       CassandraOperations cassandraOps = new CassandraTemplate(session);

       cassandraOps.insert(new Person("1234567890", "David", 40));

and Person.java is below:

@Table
public class Person {
 @PrimaryKey
 private String id;

 private String name;
 private int age;

 public Person(String id, String name, int age) {
  this.id = id;
  this.name = name;
  this.age = age;
 }

 public String getId() {
  return id;
 }

 public String getName() {
  return name;
 }

 public int getAge() {
  return age;
 }

 @Override
 public String toString() {
  return "Person [id=" + id + ", name=" + name + ", age=" + age + "]";
 }

}

While exeucting the code, i get the below exception:

Exception in thread "main" java.lang.NoSuchMethodError: com.datastax.driver.core.DataType.asJavaClass()Ljava/lang/Class;
    at org.springframework.data.cassandra.mapping.CassandraSimpleTypeHolder.<clinit>(CassandraSimpleTypeHolder.java:62)
    at org.springframework.data.cassandra.mapping.BasicCassandraMappingContext.<init>(BasicCassandraMappingContext.java:73)
    at org.springframework.data.cassandra.convert.MappingCassandraConverter.<init>(MappingCassandraConverter.java:77)
    at org.springframework.data.cassandra.core.CassandraTemplate.<init>(CassandraTemplate.java:75)
    at com.axia.global.dao.cassandra.service.CassandraApp.main(CassandraApp.java:26)

Can someone please help me out with the suggestions or pointers?

2
  • 1
    Upgrade to Spring Data Cassandra 1.5.0 M1 (also spring-cql). Commented Dec 16, 2016 at 18:42
  • 1
    It did not work and had some other issues. I stopped the idea of using spring-cassandra-data and instead using the datastax drivers which seems to be working fine. Thanks for your response. Commented Dec 17, 2016 at 5:27

1 Answer 1

0

change pom file as below solved my issue:

<dependency>
        <groupId>org.cassandraunit</groupId>
        <artifactId>cassandra-unit-spring</artifactId>
        <version>3.1.1.0</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.cassandraunit</groupId>
                <artifactId>cassandra-unit</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.cassandraunit</groupId>
        <artifactId>cassandra-unit</artifactId>
        <classifier>shaded</classifier>
        <version>3.1.1.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-core</artifactId>
        <version>3.1.1</version>
        <optional>true</optional>
        <!--<exclusions>-->
        <!--<exclusion>-->
        <!--<groupId>com.google.guava</groupId>-->
        <!--<artifactId>guava</artifactId>-->
        <!--</exclusion>-->
        <!--</exclusions>-->
    </dependency>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.