Replicated Cache in ehcache and spring-boot - spring-boot

ehcache version 2.8.3 is being used in spring-boot.
The server to be tested is server A and server B based on linux
There are three kinds of cache
Below is the ehcache.xml configuration.
<ehcache>
<diskStore path="java.io.tmpdir" />
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=40001,
timeToLive=1 ,replicatePuts=true,replicatePutsViaCopy=true ,replicateUpdates=true ,replicateUpdatesViaCopy=false,
replicateRemovals=true ,replicateAsynchronously=false"/>
<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="socketTimeoutMillis=2000, port=40001"/>
<cache name="aCache"
maxElementsInMemory="0"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
<bootstrapCacheLoaderFactory
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
properties="bootstrapAsynchronously=true"
propertySeparator="," />
<!-- <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true,
replicateUpdatesViaCopy=false, replicateRemovals=true"/> -->
</cache>
<cache name="bCache"
maxElementsInMemory="0"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
<bootstrapCacheLoaderFactory
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
properties="bootstrapAsynchronously=true"
propertySeparator="," />
</cache>
<cache name="cCache"
maxElementsInMemory="0"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
<bootstrapCacheLoaderFactory
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
properties="bootstrapAsynchronously=true"
propertySeparator="," />
</cache>
</ehcache>
Ehcache.xml on Server A and Server B are entered with the same settings.
When I add a cache on server A, I want to see the a cache added on server B
Only the following logs would be displayed, but Server B could not check the added cache.
[Multicast Heartbeat Receiver Thread] DEBUG n.s.e.d.MulticastKeepaliveHeartbeatReceiver - rmiUrls received //192.168.10.20:40001/aCache|//192.168.10.20:40001/bCache|//192.168.10.20:40001/cCache
If you know how, please let me know.

Related

Infinispan [Add a new Node in a existant cluster]

i want to save my application's data using infinispan when my servers are stopped.``
for your information , in my project i have 4 nodes in my cluster and i want to add a new node which will just contain my data.and i dont know how to add it.
here is my configuration :
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:9.4 http://infinispan.org/schemas/infinispan-config-9.4.xsd"
xmlns="urn:infinispan:config:9.4">
<jgroups>
<stack-file name="tcpStack" path="${infinispan.configClusterFilePath:ispn/moose-jgroups-tcp.xml}"/>
</jgroups>
<cache-container default-cache="moose-data" statistics="true">
<transport stack="tcpStack" cluster="mooseCluster"/>
<jmx/>
<replicated-cache name="moose-data" mode="SYNC" remote-timeout="1000">
<state-transfer timeout="1000"/>
<locking acquire-timeout="1000"/>
<transaction mode="NON_XA" locking="PESSIMISTIC"/>
</replicated-cache>
</cache-container>
moose-jgroups-tcp.xml:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:org:jgroups"
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.0.xsd">
<TCP bind_addr="${infinispan.jgroups.tcp.address:127.0.0.1}"
bind_port="${infinispan.jgroups.tcp.port:7800}"
enable_diagnostics="false"
thread_naming_pattern="pl"
send_buf_size="640k"
sock_conn_timeout="300"
bundler_type="no-bundler"
thread_pool.min_threads="${infinispan.jgroups.thread_pool.min_threads:0}"
thread_pool.max_threads="${infinispan.jgroups.thread_pool.max_threads:200}"
thread_pool.keep_alive_time="60000"/>
<TCPPING
initial_hosts="${infinispan.jgroups.tcpping.initialhosts}"
port_range="0"
ergonomics="false"
/>
<MERGE3 min_interval="10000"
max_interval="30000"/>
<FD_SOCK/>
<FD_ALL timeout="6000"
interval="1500"
timeout_check_interval="500"/>
<VERIFY_SUSPECT timeout="500"/>
<pbcast.NAKACK2 use_mcast_xmit="false"
xmit_interval="100"
xmit_table_num_rows="50"
xmit_table_msgs_per_row="1024"
xmit_table_max_compaction_time="30000"
resend_last_seqno="true"/>
<UNICAST3 xmit_interval="100" xmit_table_num_rows="50"
xmit_table_msgs_per_row="1024"
xmit_table_max_compaction_time="30000"/>
<pbcast.STABLE stability_delay="500"
desired_avg_gossip="5000"
max_bytes="1M"/>
<pbcast.GMS print_local_addr="false"
join_timeout="${infinispan.jgroups.join_timeout:1000}"/>
<MFC max_credits="2m"
min_threshold="0.40"/>
<FRAG3/>
can you help me please ? thanks in advance

Spring ehcache IllegalArgumentException: Cannot find cache named

I Am working in the spring ehcache, where i have the below coding in which the spring junit is working fine. But if run this from my code it is throwing error as below
java.lang.IllegalArgumentException: Cannot find cache named 'productCategoryCache' for Builder[public com.tagit.mobeixbank.db.domain.CardsProductSTB com.tagit.mobeixbank.db.util.MobeixBankCacheManager.getAccountProductDetail(java.lang.String)] caches=[productCategoryCache] | key='' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
and I have java code here
#Override
#Cacheable(value="productCategoryCache", key="'productCategories'")
public CardsProductSTB getProductCodeByProductId(String productId) throws ModelException {
LOG.info("getProductCodeByProductId : "+productId);
//my db logic
} catch (Exception e) {
e.printStackTrace();
throw new ModelException("Error occured in [CardsProductSTB.findByProductId]", e);
} finally {
closeSession();
}
return productDetails;
}
Below is my context xml config:`
<diskStore path="java.io.tmpdir/mobeix" />
<defaultCache maxEntriesLocalHeap="10000" eternal="false"
timeToIdleSeconds="120" timeToLiveSeconds="120" diskSpoolBufferSizeMB="30"
maxEntriesLocalDisk="10000000" diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU" statistics="true">
<persistence strategy="localTempSwap" />
</defaultCache>
<cache name="productCategoryCache" maxEntriesLocalHeap="1000"
maxEntriesLocalDisk="1000" eternal="false" diskSpoolBufferSizeMB="20"
timeToIdleSeconds="200" timeToLiveSeconds="500"
memoryStoreEvictionPolicy="LFU" transactionalMode="off">
<persistence strategy="localTempSwap" />
</cache>
<cache name="transactionMatrixCache" maxEntriesLocalHeap="1000"
maxEntriesLocalDisk="1000" eternal="false" diskSpoolBufferSizeMB="20"
timeToIdleSeconds="200" timeToLiveSeconds="500"
memoryStoreEvictionPolicy="LFU" transactionalMode="off">
<persistence strategy="localTempSwap" />
</cache>
</ehcache>`
Please help me where am doing wrong. This issue eating my hell lot of time.

terracotta + ehcache connect successful,but throw exception java.lang.ArrayIndexOutOfBoundsException: 28526

I install four terracotta server,the ip is
192.168.24.2
192.168.24.3
192.168.24.4
192.168.24.5
tc-config.xml is this
<?xml version="1.0" encoding="UTF-8" ?>
<tc:tc-config xmlns:tc="http://www.terracotta.org/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-6.xsd">
<tc-properties>
<property name="l2.nha.dirtydb.autoDelete" value="true"/>
<property name="l1.cachemanager.enabled" value="true"/>
<property name="l2.l1reconnect.timeout.millis" value="5000"/>
<property name="logging.maxLogFileSize" value="1024"/>
</tc-properties>
<servers>
<server host="192.168.24.2" name="node1" bind="192.168.24.2">
<data>/opt/terracotta-3.7.0/server-data</data>
<logs>/opt/terracotta-3.7.0/server-logs</logs>
<index>/opt/terracotta-3.7.0/server-index</index>
<statistics>/opt/terracotta-3.7.0/server-statistics</statistics>
<dso-port bind="192.168.24.2">9510</dso-port>
<jmx-port bind="192.168.24.2">9520</jmx-port>
<l2-group-port bind="192.168.24.2">9530</l2-group-port>
<dso>
<client-reconnect-window>120</client-reconnect-window>
<persistence>
<mode>temporary-swap-only</mode>
</persistence>
<garbage-collection>
<enabled>true</enabled>
<verbose>false</verbose>
<interval>3600</interval>
</garbage-collection>
</dso>
</server>
<server host="192.168.24.3" name="node2" bind="192.168.24.3">
<data>/opt/terracotta-3.7.0/server-data</data>
<logs>/opt/terracotta-3.7.0/server-logs</logs>
<index>/opt/terracotta-3.7.0/server-index</index>
<statistics>/opt/terracotta-3.7.0/server-statistics</statistics>
<dso-port bind="192.168.24.3">9510</dso-port>
<jmx-port bind="192.168.24.3">9520</jmx-port>
<l2-group-port bind="192.168.24.3">9530</l2-group-port>
<dso>
<client-reconnect-window>120</client-reconnect-window>
<persistence>
<mode>temporary-swap-only</mode>
</persistence>
<garbage-collection>
<enabled>true</enabled>
<verbose>false</verbose>
<interval>3600</interval>
</garbage-collection>
</dso>
</server>
<server host="192.168.24.4" name="node3" bind="192.168.24.4">
<data>/opt/terracotta-3.7.0/server-data</data>
<logs>/opt/terracotta-3.7.0/server-logs</logs>
<index>/opt/terracotta-3.7.0/server-index</index>
<statistics>/opt/terracotta-3.7.0/server-statistics</statistics>
<dso-port bind="192.168.24.4">9510</dso-port>
<jmx-port bind="192.168.24.4">9520</jmx-port>
<l2-group-port bind="192.168.24.4">9530</l2-group-port>
<dso>
<client-reconnect-window>120</client-reconnect-window>
<persistence>
<mode>temporary-swap-only</mode>
</persistence>
<garbage-collection>
<enabled>true</enabled>
<verbose>false</verbose>
<interval>3600</interval>
</garbage-collection>
</dso>
</server>
<server host="192.168.24.5" name="node4" bind="192.168.24.5">
<data>/opt/terracotta-3.7.0/server-data</data>
<logs>/opt/terracotta-3.7.0/server-logs</logs>
<index>/opt/terracotta-3.7.0/server-index</index>
<statistics>/opt/terracotta-3.7.0/server-statistics</statistics>
<dso-port bind="192.168.24.5">9510</dso-port>
<jmx-port bind="192.168.24.5">9520</jmx-port>
<l2-group-port bind="192.168.24.5">9530</l2-group-port>
<dso>
<client-reconnect-window>120</client-reconnect-window>
<persistence>
<mode>temporary-swap-only</mode>
</persistence>
<garbage-collection>
<enabled>true</enabled>
<verbose>false</verbose>
<interval>3600</interval>
</garbage-collection>
</dso>
</server>
<mirror-groups>
<mirror-group group-name="ehcache-group">
<members>
<member>node1</member>
<member>node2</member>
<member>node3</member>
<member>node4</member>
</members>
<ha>
<mode>networked-active-passive</mode>
<networked-active-passive>
<election-time>5</election-time>
</networked-active-passive>
</ha>
</mirror-group>
</mirror-groups>
<ha>
<mode>networked-active-passive</mode>
<networked-active-passive>
<election-time>5</election-time>
</networked-active-passive>
</ha>
</servers>
<clients>
<logs>/opt/terracotta-3.7.0/clients-logs/logs-%i</logs>
</clients>
the ehcache-terracotta.xml is this
<?xml version="1.0" encoding="UTF-8"?>
<ehcache updateCheck="false" name="defaultCache">
<diskStore path="java.io.tmpdir" />
<cacheManagerEventListenerFactory class="" properties=""/>
<terracottaConfig url="192.168.24.2:9510,192.168.24.3:9510,192.168.24.4:9510,192.168.24.5:9510"/>
<!-- <terracottaConfig url="192.168.24.2:9510"/> -->
<defaultCache maxEntriesLocalHeap="1000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600"
overflowToDisk="false" maxElementsOnDisk="1000000" statistics="true">
<terracotta clustered="true" localCacheEnabled="false"/>
</defaultCache>
<cache name="sysCache" maxEntriesLocalHeap="1000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="false" maxElementsOnDisk="1000000" statistics="true">
<terracotta clustered="true" localCacheEnabled="false"/>
</cache>
<cache name="userCache" maxEntriesLocalHeap="1000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="false" maxElementsOnDisk="1000000" statistics="true">
<terracotta clustered="true" localCacheEnabled="false"/>
</cache>
<cache name="corpCache" maxEntriesLocalHeap="1000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="false" maxElementsOnDisk="1000000" statistics="true">
<terracotta clustered="true" localCacheEnabled="false"/>
</cache>
<cache name="cmsCache" maxEntriesLocalHeap="1000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="false" maxElementsOnDisk="1000000" statistics="true">
<terracotta clustered="true" localCacheEnabled="false"/>
</cache>
<cache name="actCache" maxEntriesLocalHeap="100" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="false" maxElementsOnDisk="1000000" statistics="true">
<terracotta clustered="true" localCacheEnabled="false"/>
</cache>
<cache name="pageCachingFilter" maxEntriesLocalHeap="1000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="false" maxElementsOnDisk="1000000" memoryStoreEvictionPolicy="LFU" statistics="true">
<terracotta clustered="true" localCacheEnabled="false"/>
</cache>
<cache name="activeSessionsCache" maxEntriesLocalHeap="10000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="false" maxElementsOnDisk="1000000"
diskPersistent="false" diskExpiryThreadIntervalSeconds="600" statistics="true">
<terracotta clustered="true" localCacheEnabled="false"/>
</cache>
if set terracottaConfig url attribute just one server & set the terracotta tag clustered attribute is false it run ok, when I set the multile terracotta server & set terracotta tag attribute 'clustered' is true. then i start the project it shows this:
2017 5:50:08 下午 net.sf.ehcache.terracotta.TerracottaClient info
Thread [localhost-startStop-1] [cacheManager: 'defaultCache']: Creating new ClusteredInstanceFactory
2017-09-19 17:50:08,838 INFO - Terracotta 3.7.0, as of 20120718-055216 (Revision 18930-20453 by cruise#su10mo128 from 3.7.0)
2017-09-19 17:50:09,304 INFO - Successfully loaded base configuration from server at '192.168.24.2:9510'.
2017-09-19 17:50:09,363 INFO - Successfully loaded base configuration from file at 'C:\Users\Admin\AppData\Local\Temp\tc-config3458563347390637739.xml'.
2017-09-19 17:50:09,397 INFO - Log file: 'D:\opt\terracotta-3.7.0\clients-logs\logs-192.168.30.83\terracotta-client.log'.
2017-09-19 17:50:10,711 INFO - Connection successfully established to server at 192.168.24.2:9510
java.lang.ArrayIndexOutOfBoundsException: 28526
at com.tc.asm.ClassReader.readClass(ClassReader.java:2015)
at com.tc.asm.ClassReader.accept(ClassReader.java:469)
at com.tc.asm.ClassReader.accept(ClassReader.java:425)
at com.tc.aspectwerkz.reflect.impl.asm.AsmClassInfo.<init>(AsmClassInfo.java:189)
at com.tc.aspectwerkz.reflect.impl.asm.AsmClassInfo.constructAsmClassInfo(AsmClassInfo.java:269)
at com.tc.aspectwerkz.reflect.impl.asm.AsmClassInfo.getClassInfo(AsmClassInfo.java:298)
at com.tc.aspectwerkz.reflect.impl.asm.AsmClassInfo.createClassInfoFromStream(AsmClassInfo.java:692)
at com.tc.aspectwerkz.reflect.impl.asm.AsmClassInfo.getClassInfo(AsmClassInfo.java:245)
at com.tc.aspectwerkz.reflect.impl.asm.AsmFieldInfo.getType(AsmFieldInfo.java:63)
at com.tc.aspectwerkz.expression.ExpressionVisitor.visit(ExpressionVisitor.java:488)
at com.tc.aspectwerkz.expression.ast.ASTFieldPattern.jjtAccept(ASTFieldPattern.java:28)
at com.tc.aspectwerkz.expression.ExpressionVisitor.visitAnnotatedNode(ExpressionVisitor.java:1016)
at com.tc.aspectwerkz.expression.ExpressionVisitor.visit(ExpressionVisitor.java:171)
at com.tc.aspectwerkz.expression.ast.ASTGet.jjtAccept(ASTGet.java:22)
at com.tc.aspectwerkz.expression.ExpressionVisitor.visit(ExpressionVisitor.java:100)
at com.tc.aspectwerkz.expression.ast.ASTExpression.jjtAccept(ASTExpression.java:22)
at com.tc.aspectwerkz.expression.ExpressionVisitor.visit(ExpressionVisitor.java:88)
at com.tc.aspectwerkz.expression.ExpressionVisitor.match(ExpressionVisitor.java:74)
at com.tc.object.config.Root.matches(Root.java:94)
at com.tc.object.config.StandardDSOClientConfigHelperImpl.findMatchingRootDefinition(StandardDSOClientConfigHelperImpl.java:1015)
at com.tc.object.config.StandardDSOClientConfigHelperImpl.classContainsAnyRoots(StandardDSOClientConfigHelperImpl.java:1023)
at com.tc.object.config.StandardDSOClientConfigHelperImpl.shouldBeAdapted(StandardDSOClientConfigHelperImpl.java:1254)
at com.tc.object.bytecode.hook.impl.DefaultWeavingStrategy.transformInternal(DefaultWeavingStrategy.java:177)
at com.tc.object.bytecode.hook.impl.DefaultWeavingStrategy.transform(DefaultWeavingStrategy.java:127)
at com.tc.object.bytecode.hook.impl.DSOContextImpl.preProcess(DSOContextImpl.java:305)
at com.tc.object.bytecode.hook.impl.DSOContextImpl.transform(DSOContextImpl.java:409)
at com.terracotta.express.ClusteredStateLoader.transform(ClusteredStateLoader.java:160)
at com.terracotta.express.ClusteredStateLoader.loadClass(ClusteredStateLoader.java:119)
at org.terracotta.modules.ehcache.store.TerracottaClusteredInstanceFactory.registerLocalResourceCacheManager(TerracottaClusteredInstanceFactory.java:279)
at org.terracotta.modules.ehcache.store.TerracottaClusteredInstanceFactory.getOrCreateStoreInternal(TerracottaClusteredInstanceFactory.java:235)
at org.terracotta.modules.ehcache.store.TerracottaClusteredInstanceFactory.getOrCreateStore(TerracottaClusteredInstanceFactory.java:228)
at org.terracotta.modules.ehcache.store.TerracottaClusteredInstanceFactory.createStore(TerracottaClusteredInstanceFactory.java:123)
at net.sf.ehcache.terracotta.StandaloneTerracottaClusteredInstanceFactory.createStore(StandaloneTerracottaClusteredInstanceFactory.java:67)
at net.sf.ehcache.terracotta.ClusteredInstanceFactoryWrapper.createStore(ClusteredInstanceFactoryWrapper.java:93)
at net.sf.ehcache.CacheManager.createTerracottaStore(CacheManager.java:570)
at net.sf.ehcache.Cache.initialise(Cache.java:1052)
at net.sf.ehcache.CacheManager.initializeEhcache(CacheManager.java:1298)
at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java:1329)
at net.sf.ehcache.CacheManager.addConfiguredCaches(CacheManager.java:750)
at net.sf.ehcache.CacheManager.doInit(CacheManager.java:451)
at net.sf.ehcache.CacheManager.init(CacheManager.java:374)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:259)
at org.springframework.cache.ehcache.EhCacheManagerFactoryBean.afterPropertiesSet(EhCacheManagerFactoryBean.java:157)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1631)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1475)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1220)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1475)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1220)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1475)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1220)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:232)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:619)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at com.thinkgem.jeesite.modules.sys.listener.WebContextListener.initWebApplicationContext(WebContextListener.java:16)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5099)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5615)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
The problem you are seeing is that DSO, the technology at the root of Terracotta 3.x, was only compliant with Java 7 as of version 3.7.3. So you most likely need to update a number of dependencies.
However, if the update path is available to you, I stronly recommend moving to Ehcache 2.10.4 / Terracotta 4.3.4 which will even run on Java 8 as you do not seem to leverage DSO in your setup.

Ehcache is not being refreshed by cacheDecorator

I am using ehcache to refresh it from DB, but seems its not being refreshed.
ehcache.xml file ->
<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"/>
<defaultCache
maxElementsInMemory="100"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
diskSpoolBufferSizeMB="30"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"/>
<!-- The cache configuration for our Currency cache -->
<cache name="cachename"
maxElementsInMemory="3000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
diskPersistent="false" >
<persistence strategy="localTempSwap" synchronousWrites="true" />
<cacheDecoratorFactory class="net.sf.ehcache.constructs.refreshahead.RefreshAheadCacheFactory"
properties="name=myCacheRefresher,
timeToRefreshSeconds=180,
batchSize=10,
numberOfThreads=4,
maximumBacklogItems=100,
evictOnLoadMiss=true" />
</cache>
</ehcache>
config.xml
<ehcache:annotation-driven cache-manager="ehcache" />
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcache" />
</bean>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" >
<property name="configLocation" value="ehcache.xml" />
</bean>
<bean id="cachingAttributeSource" class="org.springmodules.cache.annotations.AnnotationCachingAttributeSource" />
CatchFetch.java
#GET
#Path("/Mymethod")
#WebMethod(operationName = "mymethodforUI")
public List<Object> mymethodforUI() {
LOGGER.info("Getting mymethod.");
return dao.mymethod("keyname");
}
CacheDAO.java
#Cacheable(value = "cachename", key = "#key")
public List<Object> mymethod(String key) {
List<Object> res -> a slow query getting from Db
return res;
}
Question 1: The caching is working good for first 180 seconds, but after 180 seconds, the cache is supposed to refresh. That behaviour is not being reflected. Can someone figure out why ?
Question 2: Is there any way I can log the timestamps when the cache refresh occurs defined by cacheDecoratorFactory?
Can you confirm that you aren't getting UnsupportedOperationException stating that refresh-ahead not supported under transactions or with GAE?
In order to have refresh ahead working you need to have a cache loader defined. Otherwise, how do you expect the cache to know how to populate a mapping?
A setup without a loader should probably throw an exception as it will not work.

Error in configuring EhCache and Spring

My Context file looks like this
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cacheManager-ref="ehcache"/>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:configLocation="classpath:spring/cache/ehcache.xml" p:shared="true"/>
My EhCache.xml looks like this:
<defaultCache eternal="false" maxElementsInMemory="1000"
overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
timeToLiveSeconds="600" memoryStoreEvictionPolicy="LRU"/>
<cache name="bdmCache" eternal="false"
maxElementsInMemory="100" overflowToDisk="false" diskPersistent="false"
timeToIdleSeconds="0" timeToLiveSeconds="300"
memoryStoreEvictionPolicy="LRU" />
I get below copied exception when i start my tomcat
28/Jul/2014 09:32:05 977 ERROR org.springframework.web.servlet.DispatcherServlet [localhost-startStop-1] - Context initialization failed (org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:467))
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 38 in XML document from class path resource [spring/web/spring-web.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 38; columnNumber: 118; The prefix "p" for attribute "p:cacheManager-ref" associated with an element type "bean" is not bound.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
Please tell me what i am missing here.
There is some problem with your namespaces configuration as the exception suggests: The prefix "p" for attribute "p:cacheManager-ref" associated with an element type "bean" is not bound.
Share your namespace configuration here. As per the current information present nothing more can be added. More on namespace and configurations here.
Related question.

Resources