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)
Related
My Mule 3.9 application exposes a rest end point.
Application is clustered and on-prem managed through Runtime Manager
Condition is: the end point which kicks off the batch process should be singleton meaning only 1 process should be running on the entire cluster. If a rest endpoint is invoked again, it should result into http status 409
For this use case, I have utilized Mule Caching - Clustered - In Memory version with below configuration
<ee:object-store-caching-strategy name="caching_strategy" doc:name="caching_strategy" keyGenerationExpression="some_key" synchronized="false" entryTTL="14400000" persistent="false" />
My flow looks like below -
<flow name="some-flow" doc:description="some-flow">
<message-properties-transformer scope="invocation" doc:name="Intialize Message Properties" mimeType="application/java">
<add-message-property key="messageId" value="#[message.rootId]"/>
</message-properties-transformer>
<ee:cache doc:name="inititiation" cachingStrategy-ref="caching_strategy" >
<logger message="process cache miss" level="INFO" doc:name="process cache miss"/>
<set-payload doc:name="initialize cache map" value="#[{'id' : flowVars.messageId}]" />
</ee:cache>
<choice doc:name="Is process already running ?" >
<when expression="#[payload.id == flowVars.messageId]">
<logger message="New process started" level="INFO" />
</when>
<otherwise>
<logger message="Process is already running" level="WARN" />
</otherwise>
</choice>
</flow>
As you can see, I am putting java.util.HashMap with 1 key-value pair in cache and checking if it already exists or not
<set-payload doc:name="initialize cache map" value="#[{'id' : flowVars.messageId}]" />
Actual functionality works great in the cluster and serves the purpose !
HOWEVER application logs are full of below **WARN** statements
org.mule.util.store.MonitoredObjectStoreWrapper -
Running expirty on org.mule.util.store.ObjectStorePartition#4648ce75 threw java.lang.IllegalArgumentException:
Cannot deserialize with a null classloader:
Cannot deserialize with a null classloader
I am not sure what is issue? The object which is in the cache is java.util.HashMap which is serializable and only key-value pair is of String.
I sense some class loader issue, but could not bring myself close to it.
Does anybody have any clue?
Thanks
Vikas
Had my hands on the ground and managed to resolve the issue with below configuration -
<ee:object-store-caching-strategy name="caching_strategy" doc:name="caching_strategy" keyGenerationExpression="some_key" synchronized="false" >
<!-- this is because my flow eturns different message than cache"
<ee:serializable-event-copy-strategy/>
<!-- manged store without persistance -->
<managed-store storeName="MyTaskInMemoryStoreForClusteredCaching"
maxEntries="1" entryTTL="14400000"
expirationInterval="3660000" persistent="false"/>
</ee:object-store-caching-strategy>
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)
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.
I'm using Apache Shiro Security.
My settings ehcache.xml
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
/>
<cache name="shiro-activeSessionCache"
maxElementsInMemory="10000"
overflowToDisk="true"
eternal="true"
timeToLiveSeconds="0"
timeToIdleSeconds="0"
diskPersistent="true"
diskExpiryThreadIntervalSeconds="600"/>
EHCache Session Cache Configuration
I use these settings on two different Tomcats. I do restart the server, the first sessions are saved, the second is not. What could it be?
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.