Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6837533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:29:19+00:00 2026-05-26T23:29:19+00:00

I am using EhCache 1.4.0, Spring 3.0.5 in a web application deployed on Tomcat

  • 0

I am using EhCache 1.4.0, Spring 3.0.5 in a web application deployed on Tomcat 6 using JRE 1.6. I am exposing via JMX the L2 cache management, like this:

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

<util:property-path id="hibernateCacheProvider" path="sessionFactory.settings.cacheProvider" />

<bean id="hibernateEhCacheManager" class="com.mycompany.spring.beans.factory.config.UnaccessibleFieldRetrievingFactoryBean">
    <property name="targetObject" ref="hibernateCacheProvider" />
    <property name="targetField" value="manager" />
    <property name="makeInstanceFieldVisible" value="true" />
</bean>

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <description>The cacheManager configuration.</description>
    <property name="targetClass" value="net.sf.ehcache.management.ManagementService" />
    <property name="staticMethod" value="net.sf.ehcache.management.ManagementService.registerMBeans" />
    <property name="arguments">
        <list>
            <ref bean="hibernateEhCacheManager" />
            <ref bean="mbeanServer" />
            <value type="boolean">true</value>
            <value type="boolean">true</value>
            <value type="boolean">true</value>
            <value type="boolean">true</value>
        </list>
    </property>
</bean>

<bean class="org.springframework.jmx.export.annotation.AnnotationMBeanExporter">
    <property name="server" ref="mbeanServer" />
    <property name="beans">
        <map>
            <entry key="Hibernate:type=statistics,application=applicationOne">
                <bean class="org.hibernate.jmx.StatisticsService">
                    <property name="statisticsEnabled" value="true" />
                    <property name="sessionFactory" ref="sessionFactory" />
                </bean>
            </entry>
        </map>
    </property>
</bean>

<bean id="hbm.properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="properties">
        <props>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.generate_statistics">false</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
            <prop key="hibernate.cache.provider_configuration_file_resource_path">applicationOne-web/ehcache.xml</prop>
            <prop key="hibernate.cache.query_cache_factory">org.hibernate.cache.StandardQueryCacheFactory</prop>
        </props>
    </property>
</bean>

I have to allow to clear all the entries in the L2 cache by using the jmxterm tool, like this:

run --bean net.sf.ehcache:type=CacheManager,name=net.sf.ehcache.CacheManager@605df3c5 clearAll

I am aware of jconsole to determine the exact CacheManager, from the context, but I may not use it for some reasons I won’t get into.

So far, so good, but suppose that my JVM (Tomcat server) has 2 applications deployed, both allowing JMX monitoring for EhCache. The names of these two MBeans will be:

net.sf.ehcache:type=CacheManager,name=net.sf.ehcache.CacheManager@605df3c5
net.sf.ehcache:type=CacheManager,name=net.sf.ehcache.CacheManager@49ff3459

As you can see they are not quite useful when trying to determine which cache to clear.

So my question is: is there any possibility to set the name of each CacheManager, in order to identify exactly which one to use to clear all the entries in the L2 cache ?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:29:19+00:00Added an answer on May 26, 2026 at 11:29 pm

    Once the hibernateEhCacheManager is available one can invoke its methods (setting the including) using the following bean definition. Normally this should do the trick renaming the CacheManager.

     <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
            <property name="targetObject">
                <ref local="hibernateEhCacheManager"/>
            </property>
            <property name="targetMethod">
                <value>setName</value>
            </property>
            <property name="arguments" value="<the_desired_name>"/>
    </bean>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

BAckground: I'm using ehcache as a cache implementation in a Spring 3.1 application. I'm
I am using ehCache to store larges amount of data. This cache is accessed
I currently have a distributed cache using EHCache via RMI that works just fine.
I am creating a web application using zkoss 5.0.4, Spring 3.0.3, Hibernate 3, and
when using ehcache rather than defining statement like <cache name=testonly.package.model.TestPOJOcategory maxElementsInMemory=200 eternal=true overflowToDisk=false timeToIdleSeconds=300
we are using web-ehcache's net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter, that configured by xml, to cache page where is
I am using Spring 3.1 Cache using EhCache currently to implement method caching. Consider
We are using EHCache with CF 8 to cache stuff on a central server
I'm building a Route Planner Webapp using Spring/Hibernate/Tomcat and a mysql database, I have
Is there a difference between using Ehcache as Hibernate's second-level cache provider and distributing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.