Getting Cache is not alive (STATUS_SHUTDOWN) Exception - spring

I'm facing below problem during running Quartz Tasks.Please anybody can help me to get out from this problem.I don't know too much about Spring and hibernate so anybody please help me .
Ehcache.xml
<ehcache>
<!-- Sets the path to the directory where cache .data files are created.
If the path is a Java System Property it is replaced by
its value in the running VM.
The following properties are translated:
user.home - User's home directory
user.dir - User's current working directory
java.io.tmpdir - Default temp file path -->
<diskStore path="java.io.tmpdir"/>
<!--Default Cache configuration. These will applied to caches programmatically created through
the CacheManager.
The following attributes are required:
maxElementsInMemory - Sets the maximum number of objects that will be created in memory
eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the
element is never expired.
overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache
has reached the maxInMemory limit.
The following attributes are optional:
timeToIdleSeconds - Sets the time to idle for an element before it expires.
i.e. The maximum amount of time between accesses before an element expires
Is only used if the element is not eternal.
Optional attribute. A value of 0 means that an Element can idle for infinity.
The default value is 0.
timeToLiveSeconds - Sets the time to live for an element before it expires.
i.e. The maximum time between creation time and when an element expires.
Is only used if the element is not eternal.
Optional attribute. A value of 0 means that and Element can live for infinity.
The default value is 0.
diskPersistent - Whether the disk store persists between restarts of the Virtual Machine.
The default value is false.
diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value
is 900 seconds.
-->
<defaultCache
maxElementsInMemory="1750000"
eternal="false"
overflowToDisk="true"
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="900"/>
<cache name="com.resolution.scheduler.model.TimeBlock"
maxElementsInMemory="80000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
/>
<cache name="com.resolution.scheduler.model.WeatherData"
maxElementsInMemory="10000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="57600"
timeToLiveSeconds="57600"
/>
<cache name="com.resolution.scheduler.model.User"
maxElementsInMemory="90000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="7200"
timeToLiveSeconds="7200"
/>
<cache name="com.resolution.scheduler.model.User.roles"
maxElementsInMemory="35000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
/>
<cache name="com.resolution.scheduler.model.TimeBlockSnapShot"
maxElementsInMemory="2000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
/>
<!-- See http://ehcache.sourceforge.net/documentation/#mozTocId258426 for how to configure caching for your objects -->
ApplicationContext-service.xml
<bean id="userCache"
class="org.springframework.security.core.userdetails.cache.EhCacheBasedUserCache">
<property name="cache">
<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="cacheManager">
<bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:shared="true" />
</property>
<property name="cacheName" value="userCache" />
</bean>
</property>
</bean>
Exception Stack Trace
org.hibernate.cache.CacheException: java.lang.IllegalStateException: The org.hibernate.cache.spi.UpdateTimestampsCache Cache is not alive (STATUS_SHUTDOWN)
at org.hibernate.cache.ehcache.internal.regions.EhcacheGeneralDataRegion.put(EhcacheGeneralDataRegion.java:112)
at org.hibernate.cache.ehcache.internal.regions.EhcacheTimestampsRegion.put(EhcacheTimestampsRegion.java:40)
at org.hibernate.cache.spi.UpdateTimestampsCache.preInvalidate(UpdateTimestampsCache.java:111)
at org.hibernate.engine.spi.ActionQueue.invalidateSpaces(ActionQueue.java:506)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:475)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:347)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350)
at org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:67)
at org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1191)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1257)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
at com.resolution.scheduler.dao.hibernate.ReportRunDaoHibernate.getReportRunsByReportScheduleIdAndDate(ReportRunDaoHibernate.java:97)
at com.resolution.scheduler.service.impl.ReportRunManagerImpl.getReportRunsByReportScheduleIdAndDate(ReportRunManagerImpl.java:82)
at sun.reflect.GeneratedMethodAccessor836.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)

Related

Share secondary cache accross different applications

We are using a CMS with secondary cache enabled:
Application.cfc
<cfset THIS.ormsettings.secondarycacheenabled = true />
<cfset THIS.ormsettings.cacheprovider = "ehcache" />
<cfset THIS.ormsettings.cacheConfig="ehcache.xml" />
ehcache.xml
<ehcache>
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="10000"
eternal="true"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="true"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
The entities are set to cacheuse="transactional" like so <cfcomponent persistent="true" entityname="news" table="mews" cacheuse="transactional">
Saving an article in the CMS works great and it instantly reflects changes after saving.
One of the sites which is managed by this CMS should share the cache with the CMS. Otherwise the application reflects the changes only after timeout value set in the site's ehcache.xml:
<ehcache>
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="1800"
timeToLiveSeconds="1800"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="true"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
Is it possible to share the cache between two different applications? Would it be possible to configure this in the two Application.cfc's?

Setting up RMI ehcache replication with proper multicast address setting

I am using replication with RMI type
I have ehcache replication working when when both cache nodes are on same hosts.
But problem arises when i have two different host in same domain, replication fails.
One cache node on windows 8 and other cache node on CentOS 6.
I am not sure what settingsneed to done for multicast to be enabled on Linux box.
I also tried with manual discovery but the program just stuck.
ehcache.xml snippet:
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446, timeToLive=32"/>
<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" properties="hostName=10.30.10.439, port=40001, socketTimeoutMillis=2000"/>
<defaultCache
maxBytesLocalHeap="256000000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="false"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
<!-- temp config: in memory cache, expire after the session is idle for 10 minutes -->
<cache name="ssoSessionStore"
maxBytesLocalHeap="64000000"
eternal="false"
timeToIdleSeconds="600"
timeToLiveSeconds="0"
overflowToDisk="false"
maxElementsOnDisk="20000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true
asynchronousReplicationIntervalMillis=100"
propertySeparator=","
/>
<bootstrapCacheLoaderFactory
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"
propertySeparator="," />
</cache>
Similar ehcache.xml I configure on other node with different IP address keeping multicast address same.
I am not sure what settings i am missing .
Please suggest.

Marsheling issue while replication cache in ehcache

I am trying to run two node ehcahe cluster on single machine.
I have created two instance of tomcat on machine and used standard manual peer mechanism to replicate cache.
My ehcahe .xml in one app is
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual, rmiUrls=//172.19.1.99:50002/messageCache|//172.19.1.99:50002/messagesCache" />
<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostName=localhost, port=40001, socketTimeoutMillis=12000" />
<defaultCache eternal="true" maxElementsInMemory="100" overflowToDisk="false" />
<cache name="messagesCache" maxElementsInMemory="10" eternal="true" overflowToDisk="false">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true,
replicateUpdatesViaCopy=false, replicateRemovals=true " />
<bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" />
</cache>
on second server ports are interchanged but when i run this app. i got this exception always
WARN [net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator]: Unable to send message to remote peer. Message was: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: com.ehcache.nagarroRMI.model.Message (no security manager: RMI class loader disabled)

Ehcache Manager

I have an application that use JDBCTemplate and Hibernate.
Both of this configure to use ehcache but exception thrown:
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 following:
JDBCTemplate configured using spring xml
Hibernate configured using hibernate.cfg.xml
Please help.
I tried to disable the default cache in ehcache.xml but failed and i have the shared property set to true which also caused fail.
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
<diskStore path="java.io.tmpdir" />
<!--<defaultCache eternal="true" maxElementsInMemory="50000"
overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"
/>
-->
<cache name="genericDao" eternal="false" maxElementsInMemory="50000"
overflowToDisk="false" memoryStoreEvictionPolicy="LFU" />
<cache name="reportDao" eternal="false" maxElementsInMemory="50000"
timeToIdleSeconds="28800" timeToLiveSeconds="28800"
overflowToDisk="false" memoryStoreEvictionPolicy="LFU" />
</ehcache>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="WEB-INF/ehcache/ehcache.xml"></property>
<property name="shared" value="true"></property>
</bean>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcache"></property>
</bean>
How to provide unique name in this case ?
Thanks.
Create two ehcache.xml configuration with different names.

ehcache diskStore location and access

I am using following configuration. I could like to see the cache file and see access the data from textpad/noteoad? is that possible? is there i can verify the data in Cache?
<cache name="cDBResponse" eternal="false"
maxElementsInMemory="100" overflowToDisk="false" diskPersistent="false"
timeToIdleSeconds="0" timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LRU">
<cacheEventListenerFactory class="com.optumhealth.authorization.service.MyCacheEventListenerFactory"/>
</cache>
You should at least set diskPersistent="true" and check the location of the default diskstorage :
by default it's defined in this node
<diskStore path="java.io.tmpdir"/>
where java.io.tmpdir will depend on your OS

Resources