@Vlad, i am not sure if this is the right forum to post this however you can guide if you have an idea
I did a PoC of Hibernate with Ehcache in my local eclipse environment with two different java processes running in two different eclipse instances and I could successfully get it working. Now, when I deploy the same in different java processes of actual product, it is failing to create hibernate session factory with following error: any help in this regard is appreciated…
Initial SessionFactory creation failed.org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:261)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:225)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:273)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1930)
at com.avaya.pim.jdbc.hibernate.HibernateUtil.initializeSessionFactory(HibernateUtil.java:137)
at com.avaya.pim.pam.PAM.main(PAM.java:208)
Caused by: org.hibernate.cache.CacheException: 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 the 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 ]
Below are the versions of Ehcache and Hibernate I am using:
- What version of Ehcache you are currently using; 2.10.5 version of ehcache
- Paste the configuration for the Cache/CacheManager you have an issue with; pasted below in description
- Add any name and version of other library or framework you use Ehcache with (e.g. Hibernate); Hibernate 4.3.11
- Providing JDK and OS versions may be useful as well.: jdk 1.7, RHEL
ehcache.xml configuration:
<ehcache xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=“ehcache.xsd” updateCheck=“true” monitoring=“autodetect” dynamicConfig=“true”>
<cache
name=“com.avaya.pim.jdbc.hibernate.PimAttribute”
maxElementsInMemory=“500”
eternal=“false”
timeToIdleSeconds=“120000”
timeToLiveSeconds=“120000”
overflowToDisk=“false”
diskPersistent=“false”
memoryStoreEvictionPolicy=“LRU”>
</cache>
</ehcache>
hibernate.cfg.xml relevent configuration:
<property name=“hibernate.cache.use_second_level_cache”>true</property>
<!-- <property name=“hibernate.cache.provider_class”>org.hibernate.cache.NoCacheProvider</property> -->
<property name=“hibernate.cache.region.factory_class”>org.hibernate.cache.ehcache.EhCacheRegionFactory</property>