After disabling Ehcache, it still appears enabled and I get an exception from buildSessionFactory


#1

Migrating from Hibernate ORM 4.2.21.Final to 5.3.5.Final. According to the Hibenate site we had to upgrade Hibernate Search as well. Upgraded from 4.4.4 to 5.10. Using ehcache 2.10.3 as second level caching provider.

Currently I’ve zero compile errors - though had to disable a bit of code to pull that of. When starting the server I got an error wrt the second level cache. I hoped to get further by disabling the cache all together by setting the following in the hibernate.properties file.

hibernate.cache.use_second_level_cache=false
hibernate.cache.use_query_cache=false

After doing that I still get the SAME error:

2018-08-16 14:56:44,493 [main] WARN  in [org.hibernate.cache.ehcache.internal.EhcacheRegionFactory.<init>(EhcacheRegionFactory.java:58)] - HHH020100: The Ehcache second-level cache provider for Hibernate is deprecated.  See https://hibernate.atlassian.net/browse/HHH-12441 for details.
2018-08-16 14:56:49,874 [main] WARN  in [org.hibernate.cache.ehcache.internal.EhcacheRegionFactory.createCache(EhcacheRegionFactory.java:153)] - HHH90001006: Missing cache[default-update-timestamps-region] was created on-the-fly. The created cache will use a provider-specific default configuration: make sure you defined one. You can disable this warning by setting 'hibernate.cache.ehcache.missing_cache_strategy' to 'create'.
14:56:49.895 [main] ERROR o.s.web.context.ContextLoader - Context initialization failed
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.CacheImplementor]

Another snippet where it goes wrong:

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
at eu.mycompany.orm.impl.SessionFactoryBuilderImpl.buildSessionFactory(SessionFactoryBuilderImpl.java:112) <--------- error starts here.

Perhaps I’m misinterpreting things but I thought the settings would prevent ehcache from being started by the Hibernate buildSessionFactory. Its ofc entirely possible its caused by something else during the migration but I like to rule things out. Any hint/pointers, its very much appreciated.

Note: I guess I can forget about the WARN text. Upgrading to ehcache 3.5.2 is planned after the migration.


#2

It should disable the cache. Try to replicate it. It could be a bug.


#3

TLDR; My bad, Disabling cache in Hiernae works as intended.

Delved deeper into our code base, turns out our Spring configuration get the hibernate properties from an "p:location=“classpath:hibernate.properties” file (in our code base) AND an optional “p:location=file:///${mycompany.home}/configuration/hibernate.properties” file. The latter override settings in the former. In the optional file the caching was set to true.

Thanks for your help, very much appreciated.