EhCache + Hibernate Cache is not alive

a 夏天 提交于 2019-12-03 04:59:47

I don't know the actual reason why this is happening, but I have a suggestion for tracking it down.

Looking at the source code for net.sf.ehcache.Cache, one can see that the 'alive' check just checks an in-memory flag, Cache.cacheStatus. It should be straightforward to run your code under the debugger, and set a breakpoint either in Cache.dispose() (where status is set to Status.STATUS_SHUTDOWN) or even in Cache.CacheStatus.changeState() (to catch any status transition).

You may find that there is in fact a bug with Hibernate, or it may be your usage. Either way, you should be able to find exactly who's changing the state of your cache to 'not alive'.

Good luck.

I don't know hibernate ehcache implementation has this property but when i used outofbox solution of ehcache i got same problem and solved with setting up shared property to false in EhCacheManagerFactoryBean or EhCacheCacheManager beans.

I don't know the actual reason either. But I have a guess that it may happen due to multiple incompatible versions of EhCache in application classpath. Check this by inspecting dependency tree with the following maven command:

mvn dependency:tree '-Dincludes=*:*cache*'

(PowerShell syntax)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!