Reputation: 29
I am using Infinispan caching as session scoped bean to cache user related data objects in a Spring MVC application.
Now we migrate to spring boot and we want to use @enableRedisHttpSession but we face the problem that the Infinispan CacheManager attached to the session is not Serializable, producing the following exception:
java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [org.infinispan.spring.provider.SpringEmbeddedCacheManagerFactoryBean]
org.springframework.core.serializer.DefaultSerializer.serialize(DefaultSerializer.java:43)
org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:63)
org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:35)
org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:50)
org.springframework.data.redis.core.AbstractOperations.rawHashValue(AbstractOperations.java:166)
org.springframework.data.redis.core.DefaultHashOperations.putAll(DefaultHashOperations.java:128)
org.springframework.data.redis.core.DefaultBoundHashOperations.putAll(DefaultBoundHashOperations.java:85)
org.springframework.session.data.redis.RedisOperationsSessionRepository$RedisSession.saveDelta(RedisOperationsSessionRepository.java:409)
org.springframework.session.data.redis.RedisOperationsSessionRepository$RedisSession.access$000(RedisOperationsSessionRepository.java:331)
org.springframework.session.data.redis.RedisOperationsSessionRepository.save(RedisOperationsSessionRepository.java:211)
org.springframework.session.data.redis.RedisOperationsSessionRepository.save(RedisOperationsSessionRepository.java:141)
org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.commitSession(SessionRepositoryFilter.java:193)
org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.access$100(SessionRepositoryFilter.java:169)
org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:127)
org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:65)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Typically we will balance user requests to multiple nodes so we need to make the cache shared between the nodes (using Redis store).
can any one help.
Upvotes: 1
Views: 1230
Reputation: 6107
You should never store an Infinispan CacheManager (or a Cache) in the session. Make it a singleton.
Infinispan is able to handle replication without the need of Redis, just make sure you enable the right Cache Mode (for example 'replicated' or 'distributed') and your user data will be available from all other nodes without needing to store the cache in Redis.
Upvotes: 2
Reputation: 5888
Obviously the cache manager is not serializable as it should not be serialized - it's not data. You have to track the field that references the SpringEmbeddedCacheManagerFactoryBean
and make that transient.
Upvotes: 2