EhCache Monitor Not Showing Cached Values

316 views
Skip to first unread message

dskiles

unread,
Jun 9, 2010, 2:36:27 PM6/9/10
to Ehcache Spring Annotations
Hello all,
I'm trying to get the ehcache spring annotations up and running in my
app. To verify things, I've hooked up the ehCache monitor. It looks
like I have things stored in the cache, but when I attempt to view the
details of the cached element, the only thing that it shows is "The
element couldn't be found in the cache anymore."

Is there some kind of gotcha that I'm missing here, or is this
expected behavior?

I'm using the default reflective hash key generator and a simple
memory cache and I can provide snippets of configuration and code if
they would be useful.

Eric Dalquist

unread,
Jun 9, 2010, 2:52:02 PM6/9/10
to ehcache-sprin...@googlegroups.com
Your ehcache.xml and the snippet of usage of the <ehcache> namesapace usage in your app context file would be quite useful.

-Eric

dskiles

unread,
Jun 9, 2010, 2:57:47 PM6/9/10
to Ehcache Spring Annotations
I've included both items below. Thank you for taking a look at this.

EhCache.xml:

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd">
<diskStore path="ehcache_swap"/>

<cacheManagerPeerListenerFactory
class="org.terracotta.ehcachedx.monitor.probe.ProbePeerListenerFactory"
properties="monitorAddress=localhost, monitorPort=9889,
memoryMeasurement=true"/>

<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
diskSpoolBufferSizeMB="30"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>

<cache name="SysPropertyCache"
maxElementsInMemory="10000"
maxElementsOnDisk="1000"
eternal="false"
overflowToDisk="true"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
diskPersistent="false" />

<cache name="ClassificationCache"
maxElementsInMemory="10000"
maxElementsOnDisk="1000"
eternal="false"
overflowToDisk="true"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
diskPersistent="false" />

<cache name="DatabaseConnectionCache"
maxElementsInMemory="10000"
maxElementsOnDisk="1000"
eternal="false"
overflowToDisk="true"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
diskPersistent="false" />

<cache name="RepositoryCache"
maxElementsInMemory="10000"
maxElementsOnDisk="1000"
eternal="false"
overflowToDisk="true"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
diskPersistent="false" />
</ehcache>


Spring Configuration:

<bean id="autoproxy"
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" /
>

<bean id="ehCacheManager"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:config/common/cache/
ehcache.xml" />
</bean>

<ehcache:annotation-driven cache-manager="ehCacheManager" />



On Jun 9, 2:52 pm, Eric Dalquist <eric.dalqu...@gmail.com> wrote:
> Your ehcache.xml and the snippet of usage of the <ehcache> namesapace usage
> in your app context file would be quite useful.
>
> -Eric
>

Nicholas Blair

unread,
Jun 9, 2010, 3:17:46 PM6/9/10
to ehcache-sprin...@googlegroups.com
I honestly hadn't heard of the Ehcache monitor product until your
message...it looks pretty neat.
I do wonder since the monitor is connecting over the "network" your
cache keys and values need to be Serializable to be viewable in the
console.

Are your keys/values Serializable? Do you know whether or not the
monitor requires it (I looked through what documentation I could find,
it doesn't make any mention).

dskiles

unread,
Jun 9, 2010, 3:22:52 PM6/9/10
to Ehcache Spring Annotations
My keys are serializable, since they come from the reflective cache
key generator.

Now that you mention it, the values probably aren't guaranteed to be
serializable. I'm a convert from the spring-modules cache that used
the XStream adapter for items that weren't serializable. Is there
anything like that for this package?

On Jun 9, 3:17 pm, Nicholas Blair <nicholas.bl...@gmail.com> wrote:
> I honestly hadn't heard of the Ehcache monitor product until your
> message...it looks pretty neat.
> I do wonder since the monitor is connecting over the "network" your
> cache keys and values need to be Serializable to be viewable in the
> console.
>
> Are your keys/values Serializable? Do you know whether or not the
> monitor requires it (I looked through what documentation I could find,
> it doesn't make any mention).
>

Eric Dalquist

unread,
Jun 9, 2010, 3:24:30 PM6/9/10
to ehcache-sprin...@googlegroups.com
There isn't, we hadn't really planned on copying that feature over though it could be done if someone has the time to implement it.

dskiles

unread,
Jun 9, 2010, 3:54:53 PM6/9/10
to Ehcache Spring Annotations
Is there any way to determine if items are in the memory cache if they
don't implement serializable? Other than this monitor, I'm not aware
of any other methods of examining the cache.

On Jun 9, 3:24 pm, Eric Dalquist <eric.dalqu...@gmail.com> wrote:
> There isn't, we hadn't really planned on copying that feature over though it
> could be done if someone has the time to implement it.
>

Eric Dalquist

unread,
Jun 9, 2010, 4:01:07 PM6/9/10
to ehcache-sprin...@googlegroups.com
We use JMX to do cache monitoring. You can easily enable this in Spring by doing:

    <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
        <property name="locateExistingServerIfPossible" value="true" />
    </bean>

    <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetClass" value="net.sf.ehcache.management.ManagementService" />
        <property name="targetMethod" value="registerMBeans" />
        <property name="arguments">
            <list>
                <ref bean="cacheManager" />
                <ref bean="mbeanServer" />
                <value>true</value>
                <value>true</value>
                <value>true</value>
                <value>true</value>
            </list>
        </property>
    </bean>

You can't see the actual data but you can see object counts.
Message has been deleted

Ankush Tehale

unread,
Jan 9, 2013, 1:45:50 PM1/9/13
to ehcache-sprin...@googlegroups.com


On Wednesday, January 9, 2013 10:40:58 AM UTC-8, Ankush Tehale wrote:

You are missing to add "statistics" property in your cache.

<cache name="SysPropertyCache"
                        
maxElementsInMemory="10000"
                        maxElementsOnDisk="1000"
                        eternal="false"
                        overflowToDisk="true"
                        diskSpoolBufferSizeMB="20"
                        timeToIdleSeconds="300"
                        timeToLiveSeconds="600"
                        memoryStoreEvictionPolicy="LFU"
                        diskPersistent="false" 
                            statistic="true"
/>
Reply all
Reply to author
Forward
0 new messages