Infinispan NotSerializableException when streaming entryset
coenenpe Jan 17, 2018 10:19 AMHi,
When running Wildfly in replicated mode we're getting a NotSerializableException.
We're using:
- Wildfly:
- Version: 10.1.0.Final
- Profile: Full-HA
- Infinispan cache:
- Embedded within Wildfly
- Setup as replicated Cache
Problem:
When we start Wildfly and only 1 server is active, we notice that all processing is succesfull (this is the server who's registered as the domain-controller)
When we add a second server we notice that we're getting the exception below when executing the same code (even on the same server)
Unexpected error while replicating: org.infinispan.commons.marshall.NotSerializableException
I found that when I'm using a 'stream' to access my entries, I'm getting an exception. When I'm using a 'for' loop I'm not hitting the exception.
So when executing the following code:
public void test(){ LOG.debug("Start executing working code"); CacheSet<map.entry<integer, mycachevalue="">> t1 = myCacheValueCacheFacade.getAll(); Set testSet = new HashSet<>(); for (Map.Entry<integer, mycachevalue=""> integerMyCacheValueEntry : t1) { Integer key = integerMyCacheValueEntry.getKey(); testSet.add(key); } LOG.debug("Stop executing working code"); LOG.debug("Start executing failing code: Step 1"); CacheStream<map.entry<integer, mycachevalue="">> t2 = t1.stream(); LOG.debug("Step 2"); Stream t3 = t2.map(v -> v.getKey()); LOG.debug("Step 3"); Set myCacheValueSet = t3.collect(Collectors.toSet()); LOG.debug("This is never printed"); }
I'm getting the following output:
Start executing working code Stop executing working code Start executing failing code: Step 1 Step 2 Step 3
Followed by this exception:
ERROR [org.infinispan.remoting.rpc.RpcManagerImpl] (EJB default - 4) ISPN000073: Unexpected error while replicating: org.infinispan.commons.marshall.NotSerializableException: be.mycompany.myproject.MyServiceClass$$Lambda$477/570154805 Caused by: an exception which occurred: in object be.mycompany.myproject.MyServiceClass$$Lambda$477/570154805@6f798c8a in object java.util.ArrayDeque@6f0caea6 in object org.infinispan.stream.impl.termop.SegmentRetryingOperation@72adc55d in object org.infinispan.stream.impl.StreamRequestCommand@702c091e
I don't understand why this is happening and what I can do to solve this.
I read about some simular problem when using Remote Caches in this topic: https://developer.jboss.org/thread/275138. Is this the same problem as I'm facing? I don't think I'm using a RemoteCache am I?
I saw simular problems being solved by william.burns andpferraro so that's the reason I'm tagging you guys here. Hope I can get your help!
Many thanks in advance!
Peter