首页 > 解决方案 > Gremlin:AbstractGryoMessageSerializerV3d0。org.apache.tinkerpop.shaded.kryo.KravyoException:遇到未注册的类 ID:65536

问题描述

我正在使用 gremlin 使用 Java 对 JanusGraph 进行查询。我的 Java 代码正在使用 Cluster client.submit(query) 触发 g.addV(...) 查询。cluster = Cluster.build() .addContactPoint("localhost") .port(8182)
.serializer(Serializers.GRAPHSON_V3D0) .maxInProcessPerConnection(32) .maxSimultaneousUsagePerConnection(32) .maxContentLength(1000000) .maxWaitForConnection(10) .minConnectionPoolSize(5 ) .maxConnectionPoolSize(20) .create();

出现以下错误:21:23:05.890 WARN - 响应 [PooledUnsafeDirectByteBuf(ridx: 393, widx: 393, cap: 393)] 无法被 org.apache.tinkerpop.gremlin.driver.ser.AbstractGryoMessageSerializerV3d0 反序列化。org.apache.tinkerpop.shaded.kryo.KryoException:在 org.apache.tinkerpop.gremlin.structure.io.gryo.AbstractGryoClassResolver.readClass(AbstractGryoClassResolver.java:148) 处遇到未注册的类 ID:65536。 shaded.kryo.Kryo.readClass(Kryo.java:670) 在 org.apache.tinkerpop.shaded.kryo.Kryo.readClassAndObject(Kryo.java:781) 在 org.apache.tinkerpop.gremlin.structure.io.gryo。 kryoshim.shaded.ShadedKryoAdapter.readClassAndObject(ShadedKryoAdapter.java:39) 在 org.apache.tinkerpop.gremlin.structure.io.gryo.kryohim.shaded.ShadedKryoAdapter.readClassAndObject(ShadedKryoAdapter.java:24) 在 org.apache.tinkerpop。

但我可以看到 Vertex 已添加到我的 Janus 中。但代码返回错误。

任何指导都会有所帮助。

谢谢

标签: gremlinjanusgraphgremlin-server

解决方案


这个问题的变体之前已经出现过(这里这里在 StackOverflow 和TINKERPOP-2372上),但一般来说,这意味着服务器上有一个序列化程序在客户端上不可用(或者相反的方式可能是不常见)。在您的情况下,您可能只需要添加JanusGraphIoRegistry到您的驱动程序配置中,如这些链接中所示,但为了方便并直接回答您的问题版本,我将使用您的Cluster构建器设置:

GryoMapper mapper = GryoMapper.build().addRegistry(JanusGraphIoRegistry.INSTANCE).create();
Cluster cluster = Cluster.build().
                          addContactPoint("localhost").port(8182).
                          serializer(new GryoMessageSerializerV1d0(mapper)).
                          maxInProcessPerConnection(32).
                          maxSimultaneousUsagePerConnection(32).
                          maxContentLength(1000000).
                          maxWaitForConnection(10).
                          minConnectionPoolSize(5).
                          maxConnectionPoolSize(20).create();

我确实觉得奇怪的是你得到了基于 Gryo 的错误,但在你的代码片段中使用了 GraphSON 序列化程序。我假设这可能只是一个糟糕的复制/粘贴情况。请注意,您可能希望查看有关配置驱动程序这一方面的 JanusGraph 文档:7.4.2.1。通过 Gremlin 服务器连接到 JanusGraph


推荐阅读