Hibernate version: 3.0.5
I'm sometimes experiencing this problem during Hibernate init phase:
Code:
org.hibernate.HibernateException: Could not instantiate cache implementation
at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:64)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at ejb.persistence.HibernateUtils.<clinit>(HibernateUtils.java:43)
at ejb.auth.UserManagerEJB.getSession(UserManagerEJB.java:34)
at ejb.auth.UserManagerEJB.findWEBUserByPrincipal(UserManagerEJB.java:132)
[snip]
Caused by: org.hibernate.cache.CacheException: net.sf.ehcache.ObjectExistsException: Cache ejb.catalog.Categoria al
ready exists
at org.hibernate.cache.EhCacheProvider.buildCache(EhCacheProvider.java:105)
at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:61)
... 17 more
Caused by: net.sf.ehcache.ObjectExistsException: Cache ejb.catalog.Categoria already exists
at net.sf.ehcache.CacheManager.addCache(CacheManager.java:301)
at org.hibernate.cache.EhCacheProvider.buildCache(EhCacheProvider.java:98)
... 18 more
I've checked both hibernate.cfg.xml and ehcache.xml, there're no duplicate class entry. Usually, restarting the application server solves the problem.
I've also noticed a duplicate log entry, right before the error:
Code:
05:01:49,240 WARN EhCacheProvider:97 - Could not find configuration [ejb.cart.OrderAddress]; using defaults.
05:01:49,344 WARN EhCacheProvider:97 - Could not find configuration [ejb.catalog.Categoria]; using defaults.
05:01:49,366 WARN EhCacheProvider:97 - Could not find configuration [ejb.catalog.Categoria]; using defaults.
Hibernate is initialized in a static block, then bound to JNDI using EJB session pattern.
I've noticed this occurs often when there are several request during startup. Is there a concurrency issue with ehcache ?