Reputation: 11
I am trying to build client application in java for gremlin. My janusgraph server is running on one more virtual machine in the same network. Through my gremlin client code i am able to establish connection between client and server but i am unable to query to server from my client application i am facing serialization and index array out of bond exception. Below is my code
public class App {
public static void main(String[] args) throws Exception{
Cluster cluster = Cluster.build()
.addContactPoint("192.168.21.121")
.port(8182)
.enableSsl(false)
.minConnectionPoolSize(1)
.maxConnectionPoolSize(10)
.maxWaitForConnection(200000)
.serializer(Serializers.GRYO_V3D0) // Adjust this based on your JanusGraph server setup
.create();
GraphTraversalSource g = traversal()
.withRemote(DriverRemoteConnection.using(cluster)
// Adjust based on server compatibility
);
try {
// Add two vertices
Vertex vertex1 = g.addV("person").property("name", "John Doe").property("age", 30).next();
Vertex vertex2 = g.addV("person").property("name", "Jane Doe").property("age", 28).next();
System.out.println("Vertices added with IDs: " + vertex1.id() + ", " + vertex2.id());
// Add an edge between the two vertices
Edge addedEdge = g.V(vertex1).addE("knows").to(vertex2).property("relationshipType", "friend").next();
System.out.println("Edge added with ID: " + addedEdge.id());
} finally {
cluster.close();
}
}
}
*-----------------------------------------------------------------------------------------------*
Error:-
prajwal@prajwal-patil:~/Desktop/test_netconf/graph$ cd /home/prajwal/Desktop/test_netconf/graph ; /usr/bin/env /usr/jdk1.8.0_202/bin/java -cp /tmp/cp_1zht1jxqth1ppqvnhvvmhm5an.jar com.janus.graph.App
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/prajwal/.m2/repository/org/slf4j/slf4j-log4j12/1.7.30/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/prajwal/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
0 [main] INFO org.apache.tinkerpop.gremlin.driver.Connection - Created new connection for ws://192.168.21.121:8182/gremlin
1 [main] INFO org.apache.tinkerpop.gremlin.driver.ConnectionPool - Opening connection pool on Host{address=192.168.21.121/192.168.21.121:8182, hostUri=ws://192.168.21.121:8182/gremlin} with core size of 1
86 [gremlin-driver-loop-1] WARN org.apache.tinkerpop.gremlin.driver.MessageSerializer - Response [SimpleLeakAwareByteBuf(PooledUnsafeDirectByteBuf(ridx: 57, widx: 57, cap: 57))] could not be deserialized by org.apache.tinkerpop.gremlin.driver.ser.AbstractGryoMessageSerializerV3d0.
java.lang.IndexOutOfBoundsException: Index: 127, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at org.apache.tinkerpop.shaded.kryo.util.MapReferenceResolver.getReadObject(MapReferenceResolver.java:60)
at org.apache.tinkerpop.shaded.kryo.Kryo.readReferenceOrNull(Kryo.java:834)
at org.apache.tinkerpop.shaded.kryo.Kryo.readObject(Kryo.java:684)
at org.apache.tinkerpop.gremlin.driver.ser.AbstractGryoMessageSerializerV3d0.deserializeResponse(AbstractGryoMessageSerializerV3d0.java:155)
at org.apache.tinkerpop.gremlin.driver.handler.WebSocketGremlinResponseDecoder.decode(WebSocketGremlinResponseDecoder.java:50)
at org.apache.tink````
I am trying to add vertex from my client application and the same need to be stored in cassendra backend.
Upvotes: 1
Views: 111
Reputation: 46226
You mention that you are using Gryo 1 in one of your comments associated with your question, but your client code in the questions says Gryo 3. I'm not clear if that's a mistake or not, but the server and the client both need the same serializer configured or else they won't communicate properly.
You also don't mention what version of TinkerPop you are using, but note that Gryo was removed as a supported serialization format in 3.6.0. It would be best if you chose GraphBinary instead.
Upvotes: 1