Serialization Issue

I have a weird error, when I am connecting with JanusGraph gremlin client using conf/remote-graph-binary.yaml I am able to get results. But when I am trying to use my java application I am getting, java.io.IOException: Serializer for custom type 'janusgraph.RelationIdentifier' not found. Googling around I got that this is due to serialization issue. It looks to me that the gremlin-client and my java application has similar configs but gremlin-client is not having any serialization problem.
hosts: [localhost]
port: 8182
serializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV1, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
hosts: [localhost]
port: 8182
serializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV1, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
Code setting up the serialization:
import org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry;
import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry;
import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV1;
...
TypeSerializerRegistry typeSerializerRegistry = TypeSerializerRegistry.build()
.addRegistry(JanusGraphIoRegistry.getInstance())
.create();

// Build cluster and connect client
Cluster cluster = Cluster.build(host)
.port(port)
.serializer(new GraphBinaryMessageSerializerV1(typeSerializerRegistry))
.maxConnectionPoolSize(1)
.minConnectionPoolSize(1)
.maxInProcessPerConnection(1)
.minSimultaneousUsagePerConnection(1)
.maxSimultaneousUsagePerConnection(1)
.create();
Client client = cluster.connect();
...
import org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry;
import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry;
import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV1;
...
TypeSerializerRegistry typeSerializerRegistry = TypeSerializerRegistry.build()
.addRegistry(JanusGraphIoRegistry.getInstance())
.create();

// Build cluster and connect client
Cluster cluster = Cluster.build(host)
.port(port)
.serializer(new GraphBinaryMessageSerializerV1(typeSerializerRegistry))
.maxConnectionPoolSize(1)
.minConnectionPoolSize(1)
.maxInProcessPerConnection(1)
.minSimultaneousUsagePerConnection(1)
.maxSimultaneousUsagePerConnection(1)
.create();
Client client = cluster.connect();
...
Solution:
I have faced a similar issue in the past (but mostly related to gremlin-python) and @Boxuan Li suggested a solution in the JanusGraph discord server. It was something like along these lines: ``` private static MessageSerializer createGraphBinaryMessageSerializerV1() { final GraphBinaryMessageSerializerV1 serializer = new GraphBinaryMessageSerializerV1();...
GitHub
citegraph/backend/src/main/resources/gremlin-server-cql.yaml at mai...
CiteGraph: A citation graph web visualizer. Contribute to Citegraph/citegraph development by creating an account on GitHub.
Jump to solution
2 Replies
Valentyn Kahamlyk
there was similar issue https://discord.com/channels/838910279550238720/1118673121625522316, maybe this will help
Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Solution
rpuga
rpuga9mo ago
I have faced a similar issue in the past (but mostly related to gremlin-python) and @Boxuan Li suggested a solution in the JanusGraph discord server. It was something like along these lines:
private static MessageSerializer createGraphBinaryMessageSerializerV1() {
final GraphBinaryMessageSerializerV1 serializer = new GraphBinaryMessageSerializerV1();
final Map<String, Object> config = new HashMap<>();
config.put(GraphBinaryMessageSerializerV1.TOKEN_IO_REGISTRIES, Collections.singletonList(JanusGraphIoRegistry.class.getName()));
serializer.configure(config, Collections.emptyMap());
return serializer;
}
private static MessageSerializer createGraphBinaryMessageSerializerV1() {
final GraphBinaryMessageSerializerV1 serializer = new GraphBinaryMessageSerializerV1();
final Map<String, Object> config = new HashMap<>();
config.put(GraphBinaryMessageSerializerV1.TOKEN_IO_REGISTRIES, Collections.singletonList(JanusGraphIoRegistry.class.getName()));
serializer.configure(config, Collections.emptyMap());
return serializer;
}
and
Cluster cluster = Cluster.build()
.addContactPoint(gremlinServer)
.port(gremlinServerPort)
// .serializer(new GraphBinaryMessageSerializerV1(typeSerializerRegistry))
.serializer(createGraphBinaryMessageSerializerV1())
.create();
Cluster cluster = Cluster.build()
.addContactPoint(gremlinServer)
.port(gremlinServerPort)
// .serializer(new GraphBinaryMessageSerializerV1(typeSerializerRegistry))
.serializer(createGraphBinaryMessageSerializerV1())
.create();
Also, here is how he suggested to setup the serializers in the JanusGraph config file: https://github.com/Citegraph/citegraph/blob/main/backend/src/main/resources/gremlin-server-cql.yaml I hope this leads you closer to a solution.
GitHub
citegraph/backend/src/main/resources/gremlin-server-cql.yaml at mai...
CiteGraph: A citation graph web visualizer. Contribute to Citegraph/citegraph development by creating an account on GitHub.
Want results from more Discord servers?
Add your server