0

I'm running into an issue trying to connect my java application to an instance of Cassandra running in graph mode. When I try to create my connection, I'm getting the following exception

java.lang.IllegalAccessError: tried to access class com.datastax.driver.core.TypeCodec from class com.datastax.driver.dse.graph.PayloadHelper
    at com.datastax.driver.dse.graph.PayloadHelper.asBytes(PayloadHelper.java:19) ~[dse-driver-1.1.2.jar:na]
    at com.datastax.driver.dse.graph.GraphOptions.rebuildDefaultPayload(GraphOptions.java:286) ~[dse-driver-1.1.2.jar:na]
    at com.datastax.driver.dse.graph.GraphOptions.<init>(GraphOptions.java:59) ~[dse-driver-1.1.2.jar:na]
    at com.datastax.driver.dse.DseCluster$Builder.getConfiguration(DseCluster.java:269) ~[dse-driver-1.1.2.jar:na]
    at com.datastax.driver.dse.DseCluster$Builder.getConfiguration(DseCluster.java:69) ~[dse-driver-1.1.2.jar:na]
    at com.datastax.driver.core.Cluster.<init>(Cluster.java:115) ~[cassandra-driver-core-2.1.9.jar:na]
    at com.datastax.driver.core.Cluster.buildFrom(Cluster.java:182) ~[cassandra-driver-core-2.1.9.jar:na]
    at com.datastax.driver.core.Cluster$Builder.build(Cluster.java:1285) ~[cassandra-driver-core-2.1.9.jar:na]
    at com.datastax.driver.dse.DseCluster$Builder.build(DseCluster.java:261) ~[dse-driver-1.1.2.jar:na]

The application doesn't do much of anything right now except initialize a bean that tries to connect to my running cassandra. I can connect to my cassandra node just fine using datastax studio and execute gremlin queries. All of the examples I've seen here and elsewhere use the same boilerplate code to connect so I'm not sure what is going on. Any threads I could follow would be much appreciated

pom

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <!-- Datastax Enterprise Graph -->

    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>dse-driver</artifactId>
        <version>1.1.2</version>
    </dependency>
</dependencies>

Initialization code

import com.datastax.driver.dse.DseCluster;
import com.datastax.driver.dse.DseSession;
import org.springframework.stereotype.Repository;

@Repository("crmGraph")
public class CrmGraph implements Storage{
private DseSession dseSession = null;
public CrmGraph() {
    DseCluster dseCluster = DseCluster.builder().addContactPoint("127.0.0.1").build();
    dseSession = dseCluster.connect();

}
...
}
  • put it in try catch and then debug and look at the exception, inside you should be able to see the exact error. – Eddie Martinez Mar 01 '17 at 22:11
  • Its the same exception that I pasted above. – Pat Cataldo Mar 01 '17 at 22:26
  • by debugging you are able to put a breakpoint and see the full exception object. And the Cassandra prints general exceptions but if you put a breakpoint and look inside you can see the specific error. – Eddie Martinez Mar 01 '17 at 22:42
  • yes, i understand. I wrapped in try/catch but the exception never makes it back out. I stepped through the debugger and when I call the build() method, I jump directly to the catch block of org.springframework.web.method.support.InvocableHandlerMethod.doInvoke() for an InvocationTargetException. When I view that exception in the debugger, I see the same exception that I've pasted above. Apologies, I'm a bit new to both spring and DSE. I've tried the same exact code in a command line application and it seems to work just fine, so it may just be how I'm invoking it from within my spring app. – Pat Cataldo Mar 01 '17 at 23:04
  • Happy day, solved my own issue. Apparently it was just a version mismatch between cassandra-drive-core versions. I noticed that in my sample command line app the version of the core driver referenced by dse-drive was different. I added a direct dependency to cassandra-drive-core:3.1.4 and it started working. Somehow I had 2.1.9 in my maven cache. – Pat Cataldo Mar 02 '17 at 00:09

0 Answers0