hba hba - 2 months ago 22
Java Question

Spark Kryo Exception - Class is not registered: com.google.common.base.Present

I am using Spark 1.6.0-cdh5.8.0.

I'm trying to use Kryo. I have guava Optional because I thought that's what spark was using.

However I cannot serialize that using Kryo because Present class has default-visibility.

So...has anyone come across this and solved it.

The following code does not work since Present is hidden...

kryo.register(com.google.common.base.Present.class)

Answer

Try:

kryo.register(Class.forName("com.google.common.base.Present"))