Non-deterministic Kryio behavior: Deserializing somtimes fails with "Encountered unregistered class ID"

725 views
Skip to first unread message

Wladimir Schamai

unread,
May 9, 2016, 5:23:01 AM5/9/16
to kryo-users
Hi all,

We use Kryo 3.0.3, everything works fine except the fact that from time to time deserialization fails with "com.esotericsoftware.kryo.KryoException: Encountered unregistered class ID:".
It happens sporadically with exactly the same input data.

It is not easy to reproduce, it happens to be non-deterministic. Has somebody experienced similar issues?
Any recommendation where to start debugging?

I appreciate your support!
Wladimir

Martin Grotzke

unread,
May 9, 2016, 3:58:23 PM5/9/16
to kryo-...@googlegroups.com
Hi Wladimir,

On 05/09/2016 11:23 AM, Wladimir Schamai wrote:
> Hi all,
>
> We use Kryo 3.0.3, everything works fine except the fact that from time
> to time deserialization fails with
> _"com.esotericsoftware.kryo.KryoException_: Encountered unregistered
> class ID:".
> It happens sporadically with exactly the same input data.

Is it really sometimes working and sometimes not with exactly the same
input data?
Then you'd be able to successfully deserialize input data that sometimes
fails. You could serialize and deserialize such an object graph using
trace logging (just set minlog's Log.TRACE() before).


> It is not easy to reproduce, it happens to be non-deterministic. Has
> somebody experienced similar issues?
> Any recommendation where to start debugging?

Do you register classes explicitely with Kryo, or is this happening
implicitely? Registering class explicitely
(+Kryo.setRegistrationRequired(true)) is always a good idea, especially
if you serialize and deserialize using different Kryo instances (and may
be on different machines). Explicit registration ensures deterministic
results, because all instances of Kryo would register the same classes
in the same order and assign the same integer IDs to them.

If you want to see which classes are registered you have to set a custom
class resolver (because there's no public access to the registrations),
like this:

class ExtClassResolver extends DefaultClassResolver {
Iterable<Registration> getRegistrations() {
return super.idToRegistration.values();
}
}

ExtClassResolver cr = new ExtClassResolver();
Kryo kryo = new Kryo(cr, new MapReferenceResolver());
// ...(de)serialize...
// print registered classes from cr.getRegistrations()...

You can also search for similar issues and see what others did
(https://github.com/EsotericSoftware/kryo/issues?utf8=%E2%9C%93&q=is%3Aissue+%22Encountered+unregistered+class+ID%22).

Cheers,
Martin



> I appreciate your support!
> Wladimir
>
> --
> 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
> <mailto:kryo-users+...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

signature.asc

Wladimir Schamai

unread,
May 11, 2016, 4:11:07 AM5/11/16
to kryo-users
Martin, thanks, your hints helped!
It looks like we solved the issue.
Wladimir

Martin Grotzke

unread,
May 11, 2016, 5:35:35 AM5/11/16
to kryo-users

Great to hear that! Can you share the solution?


--
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.

Wladimir Schamai

unread,
May 17, 2016, 1:02:49 PM5/17/16
to kryo-users
Hi,

yes, I intended to... But then, using another set of data, the issue occurred again.
So I am still struggling. It appears to occur only for larger sets. Trying to reproduce it with smaller data set has not worked yet.

Following your recommendation I turned on the logs (Log.TRACE() ), registered all classes (even though this is not possible for our application because it is based on Eclipse plugins architecture so that classes of objects to be serialized are not known in advanced). Now I am different Kryo instances for serializing and deserializing (this solved the initial issue). All that has not helped yet.

With the latest set of data, the behavior is still non-deterministic... Now even the errors change beween "Unable to find class: " and "Encountered unregistered class ID"

Can you recommend any other things I should try?


Regards,
Wladimir

Anish Abraham

unread,
Mar 11, 2020, 3:38:08 AM3/11/20
to kryo-users
Hello Wladimir, 
I know this issue has is very old, but were you able to discover a solution to this issue? We are facing a similar issue in an Eclipse OSGi application and would appreciate any insight you may have on this. 

Best regards, 
Anish
Reply all
Reply to author
Forward
0 new messages