Problem deserializing bytecode enhanced entity from redisson second level cache


Since we updated our dependency from redisson-hibernate-53 from 3.18 to any more recent one we have errors with deserialization from the Redis server. Stack traces look like:

java.lang.ClassCastException: class org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer$1 cannot be cast to class [Ljava.lang.Object; (org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer$1 is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @3f985a86; [Ljava.lang.Object; is in module java.base of loader 'bootstrap')
at org.hibernate.type.ComponentType.assemble(
at org.hibernate.type.CollectionType.assemble(
at org.hibernate.type.TypeHelper.assemble(
at org.hibernate.cache.spi.entry.StandardCacheEntryImpl.assemble(
at org.hibernate.loader.entity.CacheEntityLoaderHelper.convertCacheEntryToEntity(
at org.hibernate.loader.entity.CacheEntityLoaderHelper.processCachedEntry(
at org.hibernate.loader.entity.CacheEntityLoaderHelper.loadFromSecondLevelCache(
at org.hibernate.persister.entity.AbstractEntityPersister.initializeEnhancedEntityUsedAsProxy(
at org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor.forceInitialize(
at org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor.lambda$handleRead$0(
at org.hibernate.bytecode.enhance.spi.interceptor.EnhancementHelper.performWork(
at org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor.handleRead(
at org.hibernate.bytecode.enhance.spi.interceptor.AbstractInterceptor.readObject(

Any suggestions?

Did you purge/clear the cache after the update? Maybe the new version uses a different serialization format.

We were spending some time on reproducing the problem this morning. We were clearing the redis cache with a clean build, made the app serve a request, noticed it been written to the cache, requested again and it failed with a stack as above. It is not an artifact of a bytecode mismatch if the same runtime is storing and reading the cache. The only change to make it work is to use Version 3.18.
What we also noticed is that there is another change necessary - the stack above only happens if we open the reflect module - else the stack message looks like:

org.hibernate.cache.CacheException: com.esotericsoftware.kryo.KryoException: java.lang.reflect.InaccessibleObjectException: Unable to make field private transient volatile boolean java.lang.reflect.Executable.hasRealParameterData accessible: module java.base does not “opens java.lang.reflect” to unnamed module @3c46e67a

Please create an issue in the issue tracker( with a test case(hibernate-test-case-templates/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ at main · hibernate/hibernate-test-case-templates · GitHub) that reproduces the issue.

Yesterday I got intel from the Redisson community, the problem is that they swapped out the default codec in V3.19. I am now trying to figure out how to inject the Reddison client that I configure in SpringBoot into the hibernate setup, which is not spring context aware. Looks like I need to create my own factory for this.