Adding a vertex causes SerializationException

268 views
Skip to first unread message

chri...@sneedleapp.com

unread,
May 20, 2016, 8:04:15 AM5/20/16
to Aurelius
I work on a Kotlin web project that uses Titan.
Currently, the web project and Titan run in distinct (AWS) instances and I communication with
Titan using Gremlin Server. I make a REST call to the web application that in turn calls the

Gremlin Server, process the response and returns a string to the client.

I can make a request to get e.g. the number of vertices, but trying to add a vertex on the
remote grapg results in a SerializationException.

Effectively, this request works fine:
    g.V().hasLabel('user').count()

This request
    g.addV(label, 'user')
is actually processed by Gremlin Server and the vertex is added properly.
However, the response cannot be serialized for some reason whatsoever. This is the Kotlin code I
use (it uses the gremlin driver Java SDK)   
    val builder = Cluster.build()
    val cluster
= builder.create()

    val client
= cluster.connect<Client>()

    val complFuture
= client.submit(req).all()
   
try {
        val ress
= complFuture.get()
       
return ress
   
} catch (e: InterruptedException) {
        e
.printStackTrace()
   
} catch (e: ExecutionException) {
        e
.printStackTrace()
   
} finally {
        client
.close()
   
}


where req is the request string (e.g. "g.V().hasLabel('user').count()" or "g.addV(label, 'user')" ).

As I said, with the first request, everything works fine.
With the second request, the method call complFuture.get() fails with the following stack trace
java.util.concurrent.ExecutionException: io.netty.handler.codec.DecoderException: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: org.apache.tinkerpop.shaded.kryo.KryoException: Encountered unregistered class ID: 65536
Serialization trace:
id
(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty)
properties
(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex)
    at java
.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
    at java
.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
    at myapp
.requests.RequestExecutor.executeRequest(RequestExecutor.kt:31)
    at myapp
.requests.AddUserRequest.execute(AddUserRequest.kt:20)
    at myapp
.rest.AddUserRestController.addUser(AddUserRestController.kt:23)
    at sun
.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun
.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java
.lang.reflect.Method.invoke(Method.java:498)
    at org
.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
    at org
.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
   
... omitted
Caused by: io.netty.handler.codec.DecoderException: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: org.apache.tinkerpop.shaded.kryo.KryoException: Encountered unregistered class ID: 65536
Serialization trace:
id
(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty)
properties
(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex)
    at io
.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99)
    at io
.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:307)
    at io
.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:293)
    at org
.apache.tinkerpop.gremlin.driver.handler.WebSocketClientHandler.channelRead0(WebSocketClientHandler.java:90)
    at io
.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io
.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:307)
    at io
.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:293)
    at io
.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:276)
    at io
.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:263)
    at io
.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:307)
    at io
.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:293)
    at io
.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:840)
    at io
.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
    at io
.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    at io
.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    at io
.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    at io
.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at io
.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
   
... 1 more
Caused by: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: org.apache.tinkerpop.shaded.kryo.KryoException: Encountered unregistered class ID: 65536
Serialization trace:
id
(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty)
properties
(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex)
    at org
.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0.deserializeResponse(GryoMessageSerializerV1d0.java:203)
    at org
.apache.tinkerpop.gremlin.driver.handler.WebSocketGremlinResponseDecoder.decode(WebSocketGremlinResponseDecoder.java:49)
    at org
.apache.tinkerpop.gremlin.driver.handler.WebSocketGremlinResponseDecoder.decode(WebSocketGremlinResponseDecoder.java:36)
    at io
.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89)
   
... 18 more
Caused by: org.apache.tinkerpop.shaded.kryo.KryoException: Encountered unregistered class ID: 65536
Serialization trace:
id
(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty)
properties
(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex)
    at org
.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolver.readClass(GryoClassResolver.java:171)
    at org
.apache.tinkerpop.shaded.kryo.Kryo.readClass(Kryo.java:667)
    at org
.apache.tinkerpop.shaded.kryo.serializers.ObjectField.read(ObjectField.java:118)
    at org
.apache.tinkerpop.shaded.kryo.serializers.FieldSerializer.read(FieldSerializer.java:557)
    at org
.apache.tinkerpop.shaded.kryo.Kryo.readClassAndObject(Kryo.java:787)
    at org
.apache.tinkerpop.shaded.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:134)
    at org
.apache.tinkerpop.shaded.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:40)
    at org
.apache.tinkerpop.shaded.kryo.Kryo.readClassAndObject(Kryo.java:787)
    at org
.apache.tinkerpop.shaded.kryo.serializers.MapSerializer.read(MapSerializer.java:161)
    at org
.apache.tinkerpop.shaded.kryo.serializers.MapSerializer.read(MapSerializer.java:39)
    at org
.apache.tinkerpop.shaded.kryo.Kryo.readObject(Kryo.java:705)
    at org
.apache.tinkerpop.shaded.kryo.serializers.ObjectField.read(ObjectField.java:125)
    at org
.apache.tinkerpop.shaded.kryo.serializers.FieldSerializer.read(FieldSerializer.java:557)
    at org
.apache.tinkerpop.shaded.kryo.Kryo.readClassAndObject(Kryo.java:787)
    at org
.apache.tinkerpop.gremlin.structure.io.gryo.GryoSerializers$VertexSerializer.read(GryoSerializers.java:77)
    at org
.apache.tinkerpop.gremlin.structure.io.gryo.GryoSerializers$VertexSerializer.read(GryoSerializers.java:66)
    at org
.apache.tinkerpop.shaded.kryo.Kryo.readClassAndObject(Kryo.java:787)
    at org
.apache.tinkerpop.shaded.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:134)
    at org
.apache.tinkerpop.shaded.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:40)
    at org
.apache.tinkerpop.shaded.kryo.Kryo.readClassAndObject(Kryo.java:787)
    at org
.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0.deserializeResponse(GryoMessageSerializerV1d0.java:190)
   
... 21 more

Why does the serialization work in the forst case, but not in the second?


  

chri...@sneedleapp.com

unread,
May 23, 2016, 9:12:29 AM5/23/16
to Aurelius
To elaborate this a little more...

The Result coming from the server offers - among others - to retrieve a Vertex.
Shouldn't the Vertex class be thus already registered with Kryo?

Stephen Mallette

unread,
May 23, 2016, 3:41:50 PM5/23/16
to Aurelius
I'm confused - you mentioned REST but then shared code using the Cluster/Client which i presume is the java gremlin-driver:


I'm going to assume that instead of REST you mean Websockets, in which case, I don't think your Cluster/Client is setup right. You need to register a titan serializer wtih the driver. Assuming you are using titan 1.0 you would do it with either a config like this:


or i think at 1.0 you could even set it programmatically with the Cluster.build() method options. In the newer (not yet released) titan 1.1.x you can just specify the TitanIoRegistry in the config or in the Cluster.build():


the point is that your driver must have the same serializers configured as the server - note the 1.1.x config here:

--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraph...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aureliusgraphs/aa224361-2f33-4ff4-a005-9bfdd42790c1%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

chri...@sneedleapp.com

unread,
May 24, 2016, 7:32:51 AM5/24/16
to Aurelius
 
I'm going to assume that instead of REST you mean Websockets, in which case, I don't think your Cluster/Client is setup right. You need to register a titan serializer wtih the driver. Assuming you are using titan 1.0 you would do it with either a config like this:


or i think at 1.0 you could even set it programmatically with the Cluster.build() method options. In the newer (not yet released) titan 1.1.x you can just specify the TitanIoRegistry in the config or in the Cluster.build():

This. And what I forgot was to give the Cluster.Builder an explicit serializer as described here:
http://tinkerpop.incubator.apache.org/docs/3.0.1-incubating/#_serialization

That the latter is needed was not obvious to me since in Cluster.Builder there is
private MessageSerializer serializer = Serializers.GRYO_V1D0.simpleInstance();
I assumed that the serializer is thus available and ready to use. Obviously, this assumption was wrong.


Reply all
Reply to author
Forward
0 new messages