Our application uses 2 session factories created from two different org.hibernate.cfg.Configurations (based on the same config file) and after updating from ehcache 2.4 to 2.6 it crashes because ehcache complains about multiple default cache managers
Caused by: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
... 14 more
This also happens no matter whether you have two org.hibernate.cfg.Configuration or just call buildSessionFactory() twice on the same Configuration.
Our application also crashes because it creates its own CacheManager but that is another topic .
I think that the Hibernate cache region factory should make sure that the CacheManager that it creates cannot cause any conflict with any other CacheManagers no matter whether they are created by Hibernate or the applicaton itself.
Fixing this seems to be quite simple
The same change would be required in SingletonEhCacheRegionFactory