Kryo NPE deserializing array

439 views
Skip to first unread message

Simone Franzini

unread,
Nov 26, 2014, 12:16:02 PM11/26/14
to kryo-...@googlegroups.com
I am using Kryo with Spark.
I have been mostly serializing/deserializing AVRO objects and that has been working great by using twitter chill serializer.

However, I am now running into the following NullPointerException when deserializing a case class that contains an array:

com.esotericsoftware.kryo.KryoException: java.lang.NullPointerException
Serialization trace:
underlying (scala.collection.convert.Wrappers$JListWrapper)
myArrayField (MyCaseClass)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125)

I found this stack overflow that seems to be relevant:
I have this line of code translated to Scala, that supposedly solves the issue:

val kryo = new Kryo()
kryo.getInstantiatorStrategy().asInstanceOf[Kryo.DefaultInstantiatorStrategy].setFallbackInstantiatorStrategy(new StdInstantiatorStrategy())

However, I am not sure where this line should be placed to take effect, since in Spark we don't explicitly instantiate kryo anywhere.

I already have the following, should it go somewhere in here?
class MyRegistrator extends KryoRegistrator {
    override def registerClasses(kryo: Kryo) {
        kryo.register(...)
    }
}

Martin Grotzke

unread,
Nov 26, 2014, 5:48:18 PM11/26/14
to kryo-users

Yes, please try to configure the kryo instance passed to registerClasses.

Cheers,
Martin

--
You received this message because you are subscribed to the "kryo-users" group.
http://groups.google.com/group/kryo-users
---
You received this message because you are subscribed to the Google Groups "kryo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kryo-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ronald Angel

unread,
Jun 1, 2017, 9:15:32 AM6/1/17
to kryo-users
Hi Simone. Did you solve this issue?
Reply all
Reply to author
Forward
0 new messages