question

bharat.asnani_190772 avatar image
bharat.asnani_190772 asked Erick Ramirez edited

Getting exception "Graph protocol 'GRAPHSON_2_0' incompatible. Use 'GraphSON 3.0 / Gryo 3.0 / GraphBinary' with Core Graph" when connecting to DSE 6.8.0

Hi,

When I am connecting to DSE 6.8.0 using java then getting the following exception:

Graph protocol 'GRAPHSON_2_0' incompatible. Use 'GraphSON 3.0 / Gryo 3.0 / GraphBinary' with Core Graph

Here is the code:

DseCluster dseCluster = DseCluster.builder()
    .withCredentials("xxxx", "xxxx")
    .addContactPoint("xx.xx.xx.xx")
    .withGraphOptions(new GraphOptions()
    .setGraphName("graph").setGraphSubProtocol(GraphProtocol.GRAPHSON_2_0))
    .build();

I have the latest dependency of DSE java graph driver (1.9.0) but it is not showing the option of GraphSON 3.0.

Any help is appreciated.

dsejava drivergraph
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

alexandre.dutra avatar image
alexandre.dutra answered alexandre.dutra edited

You are mixing incompatible driver artifacts. Let me explain:

  1. You seem to be using the Java driver 4.6.1. Please note that this driver has all the features you need, including support for DSE Graph.
  2. You don't need the DSE driver 1.9.0 at all. Please remove this dependency. (This is our legacy driver for DataStax Enterprise.)

In summary, change your dependencies to just these ones:

<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core</artifactId>
<version>4.6.1</version>
</dependency>

<!-- if you need the query builder -->
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-query-builder</artifactId>
<version>4.6.1</version>
</dependency>

<!-- if you need the mapper -->
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-mapper-runtime</artifactId>
<version>4.6.1</version>
</dependency>

Now, onto your second problem: the graph protocol.

  1. DSE 6.8 Core Graph only accepts two graph protocols: graphson-3.0, graph-binary-1.0.
  2. The Java driver 4.6.1 supports the following graph protocols: graphson-1.0, graphson-2.0, graph-binary-1.0.

Therefore, to connect to a DSE 6.8 Core Graph with driver 4.6.1, there is only one matching graph protocol: graph-binary-1.0.

In theory, this is the graph protocol that the driver will use automatically when connecting to DSE 6.8, but just to be on the safe side, you can force it in the driver configuration:

datastax-java-driver.advanced.graph.sub-protocol=graph-binary-1.0

Good luck!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image
Erick Ramirez answered bharat.asnani_190772 commented

@bharat.asnani_190772 As the exception stated, GRAPHSON_2_0 is not supported in DSE 6.8.0.

You'll need to upgrade to at least Java driver version 4.5.0 to use GraphSON3 or GraphBinary. Cheers!

5 comments Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

bharat.asnani_190772 avatar image bharat.asnani_190772 commented ·

@Erick Ramirez thanks for the reply but I am already using Java driver version 4.6.1 then also it is not showing option for GraphSON3. I am using these versions.

0 Likes 0 ·
Erick Ramirez avatar image Erick Ramirez ♦♦ bharat.asnani_190772 commented ·

This is what you said in your original post:

I have the latest dependency of DSE java graph driver (1.9.0)

Will you please check again? Cheers!

0 Likes 0 ·
bharat.asnani_190772 avatar image bharat.asnani_190772 Erick Ramirez ♦♦ commented ·

The DSE java graph driver (1.9.0) is the latest on the maven repository. Rest for the java-driver-core I am using 4.6.1. Please let me know if there is updated version of the java graph driver as I am stuck at this point.

0 Likes 0 ·
Show more comments
bettina.swynnerton avatar image
bettina.swynnerton answered

Here is a simple example for a traversal on Graph 6.8, using the unified Datastax java driver version 4.6.1.

import com.datastax.dse.driver.api.core.graph.GraphNode;
import com.datastax.dse.driver.api.core.graph.GraphResultSet;
import com.datastax.dse.driver.api.core.graph.ScriptGraphStatement;
import com.datastax.oss.driver.api.core.CqlSession;

public class SimpleTraversal {


    public static void main(String[] args) {

        try (CqlSession session = CqlSession.builder().build()) {

            String script = "g.V().has('person','person_id', 'person1').elementMap()";
            ScriptGraphStatement statement =
                    ScriptGraphStatement.builder(script).build();

            GraphResultSet result = session.execute(statement);
            for (GraphNode node : result) {
                System.out.println(node);
                
            }
        }
    }
}

Note that a few important things have changed between the dse driver version 1.9 and the unified driver version 4.6.1.

For a start, you no longer have the DSECluster object.

Instead, the contact points, the datacenter name and the graph name (and options, if you need to set them), are set in a configuration file.

From the driver docs:

- The driver JAR comes with a reference.conf file that defines the defaults.

- You can add an application.conf file in the classpath (or an absolute path, or an URL). It only needs to contain the options that you override.

https://docs.datastax.com/en/developer/java-driver/4.6/manual/core/configuration/

To get the above code example working, I explicitly set the contact point, the datacenter and the graph name in the application.conf (otherwise a copy of the reference.conf).

You also then only need the java driver 4.6.1 dependencies, not the DSE driver dependency, as listed here:

https://docs.datastax.com/en/developer/java-driver/4.6/

And then GraphSON 3 is picked by default when you connect to a 6.8 based graph, and there is no need to set it explicitly in your configuration file.

I hope this gets you up and running.

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.