Serialize custom sack

When trying to return the value of a custom sack object with .sack(), following error is thrown:
2023-02-03 12:40:20 java.lang.IllegalArgumentException: Class is not registered: org.apache.tinkerpop.gremlin.server.jsr223.ScriptData
2023-02-03 12:40:20 Note: To register this class use: kryo.register(org.apache.tinkerpop.gremlin.server.jsr223.ScriptData.class);
2023-02-03 12:40:20 at org.apache.tinkerpop.shaded.kryo.Kryo.getRegistration(Kryo.java:488)
2023-02-03 12:40:20 at org.apache.tinkerpop.gremlin.structure.io.gryo.AbstractGryoClassResolver.writeClass(AbstractGryoClassResolver.java:110)
2023-02-03 12:40:20 at org.apache.tinkerpop.shaded.kryo.Kryo.writeClass(Kryo.java:517)
2023-02-03 12:40:20 at org.apache.tinkerpop.shaded.kryo.Kryo.writeClassAndObject(Kryo.java:622)
2023-02-03 12:40:20 at org.apache.tinkerpop.shaded.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:100)
2023-02-03 12:40:20 at org.apache.tinkerpop.shaded.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:40)
...
2023-02-03 12:40:20 java.lang.IllegalArgumentException: Class is not registered: org.apache.tinkerpop.gremlin.server.jsr223.ScriptData
2023-02-03 12:40:20 Note: To register this class use: kryo.register(org.apache.tinkerpop.gremlin.server.jsr223.ScriptData.class);
2023-02-03 12:40:20 at org.apache.tinkerpop.shaded.kryo.Kryo.getRegistration(Kryo.java:488)
2023-02-03 12:40:20 at org.apache.tinkerpop.gremlin.structure.io.gryo.AbstractGryoClassResolver.writeClass(AbstractGryoClassResolver.java:110)
2023-02-03 12:40:20 at org.apache.tinkerpop.shaded.kryo.Kryo.writeClass(Kryo.java:517)
2023-02-03 12:40:20 at org.apache.tinkerpop.shaded.kryo.Kryo.writeClassAndObject(Kryo.java:622)
2023-02-03 12:40:20 at org.apache.tinkerpop.shaded.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:100)
2023-02-03 12:40:20 at org.apache.tinkerpop.shaded.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:40)
...
The solution seems to be simple: To register this class use: kryo.register, but I can't find any documentation on how to do this for over a day now. Can you please provide me a hint in the right direction?
Solution:
TinkerPop completely retired Gryo (kryo) for use as a network serialization format in 3.6.x. You should probably switch to GraphBinary serialization. With GraphBinary you will get a similar problem though. You would need to write a custom serializer for your object and install it in the client and server GraphBinaryMessageSerializer. The format for GraphBinary custom objects is shown here: https://tinkerpop.apache.org/docs/current/dev/io/#_custom There are tests that show how to create a custo...
GitHub
tinkerpop/SamplePersonSerializerTest.java at 3.5.5 · apache/tinkerpop
Apache TinkerPop - a graph computing framework. Contribute to apache/tinkerpop development by creating an account on GitHub.
Jump to solution
1 Reply
Solution
spmallette
spmallette17mo ago
TinkerPop completely retired Gryo (kryo) for use as a network serialization format in 3.6.x. You should probably switch to GraphBinary serialization. With GraphBinary you will get a similar problem though. You would need to write a custom serializer for your object and install it in the client and server GraphBinaryMessageSerializer. The format for GraphBinary custom objects is shown here: https://tinkerpop.apache.org/docs/current/dev/io/#_custom There are tests that show how to create a custom serializer and how to configure it here: https://github.com/apache/tinkerpop/blob/3.5.5/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/binary/types/sample/SamplePersonSerializerTest.java I hope it's clear that the code based configuration performed in the tests could just as well be done in the the yaml config files.
GitHub
tinkerpop/SamplePersonSerializerTest.java at 3.5.5 · apache/tinkerpop
Apache TinkerPop - a graph computing framework. Contribute to apache/tinkerpop development by creating an account on GitHub.