हाइबरनेट v3.6.7 के लिए दूसरे स्तर कैश के रूप में EhCache v2.4.5 को कॉन्फ़िगर करने के बाद मुझे हाइबरनेट सत्र का उपयोग करके किसी विशेष इकाई की सभी ऑब्जेक्ट्स लोड करने का प्रयास करते समय निम्न त्रुटि मिलती है। (वहाँ पहली बार के लिए वस्तुओं लोड करने के लिए कोई त्रुटि है)EhCache + Hibernate कैश जीवित नहीं है
java.lang.IllegalStateException: The country Cache is not alive.
at net.sf.ehcache.Cache.checkStatus(Cache.java:2438)
at net.sf.ehcache.Cache.get(Cache.java:1541)
at net.sf.ehcache.hibernate.regions.EhcacheTransactionalDataRegion.get(EhcacheTransactionalDataRegion.java:105)
at net.sf.ehcache.hibernate.strategy.AbstractReadWriteEhcacheAccessStrategy.putFromLoad(AbstractReadWriteEhcacheAccessStrategy.java:90)
at net.sf.ehcache.hibernate.nonstop.NonstopAwareEntityRegionAccessStrategy.putFromLoad(NonstopAwareEntityRegionAccessStrategy.java:180)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:195)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:982)
at org.hibernate.loader.Loader.doQuery(Loader.java:857)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at dataAccess.CountryDAO.loadAll(CountryDAO.java:80)
मेरे हाइबरनेट विन्यास है:
<property name="hibernate.cache.region.factory_class">
net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
</property>
<property name="hibernate.cache.provider_configuration">
/ehcache.xml
</property>
<property name="hibernate.cache.use_second_level_cache">
true
</property>
<property name="hibernate.cache.use_query_cache">
true
</property>
मेरे ehcache विन्यास है:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
monitoring="autodetect" dynamicConfig="true">
<diskStore path="java.io.tmpdir" />
<transactionManagerLookup
class="net.sf.ehcache.transaction.manager.DefaultTransactionManagerLookup"
properties="jndiName=java:/TransactionManager" propertySeparator=";" />
<cacheManagerEventListenerFactory
class="" properties="" />
<defaultCache maxElementsInMemory="0" eternal="false"
overflowToDisk="true" timeToIdleSeconds="1200" timeToLiveSeconds="1200">
</defaultCache>
<cache name="country"
maxElementsInMemory="300" eternal="false" overflowToDisk="false"
timeToIdleSeconds="12000" timeToLiveSeconds="12000" diskPersistent="false"
diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" />
<cache name="city"
maxElementsInMemory="300" eternal="false" overflowToDisk="false"
timeToIdleSeconds="12000" timeToLiveSeconds="12000" diskPersistent="false"
diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" />
</ehcache>
मैं कोई सुराग नहीं है क्या गलत हो रहा है कोई विचार?
आप hibernate.cache.provider_class प्रॉपर्टी को net.sf.ehcache.hibernate.EhCacheProvider – frictionlesspulley
पर सेट कर सकते हैं क्या कोई कारण है कि आप अपनी ehcache.xml फ़ाइल को "/ehcache.xml" के रूप में संदर्भित कर रहे हैं, हाइबरनेट है इसे उठाते हुए? यदि वे एक ही कक्षा में हैं, तो आपको इसका संदर्भ नहीं देना है। – artgon
मैंने एह कैशप्रोवाइडर को भी वही समस्या मौजूद करने की कोशिश की है, और ehcache.xml के बारे में आप सही हैं, हाइबरनेट इसे चुनता है, इसलिए यह कोई नुकसान नहीं करता है हालांकि यह अनावश्यक है। – Saffar