Wildfly 23, infinispan cannot marshal serializable classes

931 views
Skip to first unread message

Martin Goldhahn

unread,
May 10, 2021, 12:59:39 PM5/10/21
to WildFly
We are in the process of moving our applications from Wildfly 10 to Wildfly 23. 
We have a replicated cache that caches instances of type CachedUser. During the replicatino of the cache we get a org.infinispan.commons.marshal.NotSerializableException.
The CachedUser instance and all their fields implemetn the Serializable interface.

This seems to be caused by the fact that the default marshaller is now ProtobufMarshaller.

We made an experiment and constructed the cache programmatically and set the marshaller to the JavaSerializationMarshaller. This works. But we want to keep the configuration in the standalone-ha.xml. 

But how do you put this configuration in the standalone-ha.xml?

--
Martin
How do you set the 

Paul Ferraro

unread,
May 10, 2021, 6:30:10 PM5/10/21
to WildFly
Can you paste the relevant cache-container configuration from your infinispan subsystem as well as the means by which you create/access your Cache instance?
In WF23, the Infinispan marshaller is auto-selected based on the associated module - so I suspect that is the source of your problem.

Martin Goldhahn

unread,
May 11, 2021, 2:23:01 AM5/11/21
to WildFly
The cache container config is:

<cache-container name="altiboxapi" default-cache="default" modules="org.wildfly.clustering.web.infinispan" statistics-enabled="true">
<replicated-cache name="altibox-api-users" statistics-enabled="true">
<locking isolation="REPEATABLE_READ" concurrency-level="600"/>
<transaction mode="BATCH"/>
<heap-memory size="524288"/>
<expiration max-idle="14400000" lifespan="43200000" interval="60000"/>
<file-store passivation="false" purge="false" fetch-state="true">
<write-behind/>
</file-store>
</replicated-cache>
</cache-container>

We inject the cache like this:
@Resource(lookup = "java:jboss/infinispan/cache/altiboxapi/altibox-api-users")
private Cache<String, CachedUser> apiUserCache;


And then we just put and get the objects on/from the cache like this:
apiUserCache.put(ticket.identifier.toString(), user);
apiUserCache.get(ticket.identifier.toString());

Paul Ferraro

unread,
May 11, 2021, 8:04:17 AM5/11/21
to WildFly
OK - as I suspected.  Remove: modules="org.wildfly.clustering.web.infinispan"
from your cache-container configuration and you should be all set.

Martin Goldhahn

unread,
May 11, 2021, 9:37:21 AM5/11/21
to WildFly
Excellent, thanks for your reply. It seems to work.
Would you care to share the details why the modules attribute has this effect?
I see that the "web" cache container in the 23.0.2.Final distribution also uses the same modules attribute. Is this a bug then?

--
Martin

Paul Ferraro

unread,
May 11, 2021, 4:36:10 PM5/11/21
to Martin Goldhahn, WildFly
On Tue, May 11, 2021 at 9:37 AM Martin Goldhahn <mgol...@gmail.com> wrote:
>
> Excellent, thanks for your reply. It seems to work.
> Would you care to share the details why the modules attribute has this effect?

The modules attribute is used to dynamically load Infinispan
extensions and to configure Infinispan's marshaller.

> I see that the "web" cache container in the 23.0.2.Final distribution also uses the same modules attribute.

The "web" cache-container uses the
"org.wildfly.clustering.web.infinispan" to configure Infinispan for
use with WildFly's distributed HttpSession manager (it is referenced
via the distributable-web subsystem), which explicitly requires
ProtoStream marshalling.
My question is, why is your altiboxapi cache-container configured with
this module?

> Is this a bug then?

No. This is intentional.
> --
> You received this message because you are subscribed to a topic in the Google Groups "WildFly" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/wildfly/CdOviD6ZEMA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to wildfly+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/00e6a1fb-fb66-4b17-a2ac-b7a0ee8bb7c7n%40googlegroups.com.

Martin Goldhahn

unread,
May 12, 2021, 9:22:20 AM5/12/21
to WildFly
Why is our cache-container configured with this module?
Well, documentation is scarce and this was the same type of cache as ours. We didn't understand how the modules affects the marshalling.
The JavaSerializationMarshaller  is in the infinispan commons. Since the infinispan main module has a dependency to infinispan commons, I guess we don't have to add the module explicitely. Is that correct.
But what is the default marshaller if no module is specified? When I read the docs it sounds like Protobuf is the default marshaller. I also noticed that the JavaSerializationMarshaller is deprecated. How can we ensure it is used if Infinispan decides to change the default behavior?

Paul Ferraro

unread,
May 12, 2021, 6:44:19 PM5/12/21
to Martin Goldhahn, WildFly
On Wed, May 12, 2021 at 9:22 AM Martin Goldhahn <mgol...@gmail.com> wrote:
>
> Why is our cache-container configured with this module?
> Well, documentation is scarce and this was the same type of cache as ours. We didn't understand how the modules affects the marshalling.

In general, look to the model reference documentation for descriptions
of attributes: https://docs.wildfly.org/23/wildscribe/subsystem/infinispan/cache-container/index.html
Unfortunately, to your point, the description of this attribute is not
very clear. I'll fix this for WF24.

> The JavaSerializationMarshaller is in the infinispan commons. Since the infinispan main module has a dependency to infinispan commons, I guess we don't have to add the module explicitely. Is that correct.

This marshaller is not exposed by WildFly. Starting with WF24, the
marshaller will be explicitly configured. Currently, there are 2
options: JBoss Marshalling and ProtoStream.

> But what is the default marshaller if no module is specified?

If no module is defined, the cache container will be configured to use
JBoss Marshalling.

> When I read the docs it sounds like Protobuf is the default marshaller. I also noticed that the JavaSerializationMarshaller is deprecated.

While JavaSerializationEncoder is deprecated - I don't think the
JavaSerializationMarshaller is.

> How can we ensure it is used if Infinispan decides to change the default behavior?

Initially, I thought that auto-configuring the marshaller would be
simpler for users. I regret that decision - hence the decision to
make this explicit starting with WF24.
Once the marshaller is explicitly configured - changes to the default
behavior of Infinispan will not affect your application, as this logic
resides in our integration code.
> To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/b83f3d12-f3cc-4fe7-b5fe-84aabc5f4d0dn%40googlegroups.com.

Martin Goldhahn

unread,
May 13, 2021, 4:14:02 PM5/13/21
to WildFly
Thank you for the clarification, I really appreciate it.

--
Martin

Reply all
Reply to author
Forward
0 new messages