'Infinispan upgrade from v11 to v13 with custom Protobuf
I have an existing application that uses Infinispan v11 with custom values stored in a JDBC store using Protobuf.
Each Java class representation of the data is annotated using @ProtoField and @ProtoFactory. The schema is generated using an interface annotated with @AutoProtoSchemaBuilder.
After upgrading to v13 the data can no longer be preloaded (or lazy-loaded), with errors like:
...
Caused by: java.lang.IllegalArgumentException: No marshaller registered for Protobuf type myproject.MyClass
at org.infinispan.protostream.impl.SerializationContextImpl.getMarshallerDelegate (SerializationContextImpl.java:459)
at org.infinispan.protostream.WrappedMessage.readMessage (WrappedMessage.java:535)
at org.infinispan.protostream.WrappedMessage.read (WrappedMessage.java:351)
at org.infinispan.protostream.ProtobufUtil.fromWrappedByteArray (ProtobufUtil.java:129)
at org.infinispan.marshall.protostream.impl.AbstractInternalProtoStreamMarshaller.objectFromByteBuffer (AbstractInternalProtoStreamMarshaller.java:97)
at org.infinispan.marshall.persistence.impl.MarshallableEntryImpl.unmarshall (MarshallableEntryImpl.java:248)
at org.infinispan.marshall.persistence.impl.MarshallableEntryImpl.unmarshall (MarshallableEntryImpl.java:239)
at org.infinispan.marshall.persistence.impl.MarshallableEntryImpl.getValue (MarshallableEntryImpl.java:77)
at org.infinispan.persistence.manager.PreloadManager.preloadEntry (PreloadManager.java:117)
Infinispan 12/13 contains a change to the Protobuf format that wraps custom types so they are isolated from internal Infinispan types. The upgrade documentation states:
In previous versions, the ProtoStream API did not correctly nest message types with the result that the messages were generated as top-level only. For this reason, if you have Protobuf messages in a persistent cache store and upgrade to Infinispan 12, then you should modify Java classes so that Protobuf annotations are at top-level. This ensures that the nesting in your persisted messages matches the nesting in your Java classes, otherwise data incompatibility issues can occur.
(https://infinispan.org/docs/stable/titles/upgrading/upgrading.html#marshalling)
My questions is - what does "modify Java classes so that Protobuf annotations are at top-level" mean? I have basic Java classes that have the field and factory annotations on them, so I'm unclear what modifications I need to make.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
