Spring Ehcache MBean Monitoring

Sam

I am using Spring 4.0.3.RELEASE and EHcache 2.8.1. on JBoss 7.1.1

With the following configuration in applicationContext.xml my caching is working good.

<cache:annotation-driven/>

<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="/WEB-INF/ehcache.xml"/>
</bean>

Now I want to add the monitoring capabilities with MBean. I changed the configuration in applicationContext.xml as follows – added 2 new beans “managementService” and “mbeanServer”, no other change. This is the current configuration.

<cache:annotation-driven/>

<bean id="managementService"
        class="net.sf.ehcache.management.ManagementService"
        init-method="init"
        destroy-method="dispose">

        <constructor-arg ref="cacheManager"/>
        <constructor-arg ref="mbeanServer"/>
        <constructor-arg index="2" value="true"/>
        <constructor-arg index="3" value="true"/>
        <constructor-arg index="4" value="true"/>
        <constructor-arg index="5" value="true"/>
 </bean>

<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="/WEB-INF/ehcache.xml"/>
</bean>    

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

With this configuration I get the following error on application server start up.

14:05:32,208 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-1) Context initialization failed: org.springframework.beans.factory.UnsatisfiedDependencyException: **Error creating bean with name 'managementService'** defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [net.sf.ehcache.CacheManager]: Could not convert constructor argument value of type [org.springframework.cache.ehcache.EhCacheCacheManager] to required type [net.sf.ehcache.CacheManager]: Failed to convert value of type 'org.springframework.cache.ehcache.EhCacheCacheManager' to required type 'net.sf.ehcache.CacheManager'; nested exception is java.lang.IllegalStateException: **Cannot convert value of type [org.springframework.cache.ehcache.EhCacheCacheManager] to required type [net.sf.ehcache.CacheManager]**: no matching editors or conversion strategy found

Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'managementService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [net.sf.ehcache.CacheManager]: Could not convert constructor argument value of type [org.springframework.cache.ehcache.EhCacheCacheManager] to required type [net.sf.ehcache.CacheManager]: Failed to convert value of type 'org.springframework.cache.ehcache.EhCacheCacheManager' to required type 'net.sf.ehcache.CacheManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.cache.ehcache.EhCacheCacheManager] to required type [net.sf.ehcache.CacheManager]: no matching editors or conversion strategy found
Priyesh

You should pass the ehcache bean to the constructor of the managementService bean not cacheManager. If you look at the definition of cacheManager the ehcache bean is passed as cacheManager. The factory bean will provide an instance of net.sf.ehcache.CacheManager.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Spring Ehcache MBean Monitoring

From Dev

Monitoring Ehcache via JMX

From Dev

Monitoring Tomcat StandardThreadExecutor's queue size (MBean)

From Dev

HikariCP - Play Framework 1.2.7 JMX MBean Monitoring

From Dev

Monitoring Tomcat StandardThreadExecutor's queue size (MBean)

From Dev

ehcache configuration in Spring framework

From Dev

Understanding EhCache with Spring/MyBatis

From Dev

Spring Boot, caching with EhCache

From Dev

Spring Boot, caching with EhCache

From Dev

Spring JMX - Purpose of <context:mbean-server>

From Dev

Can't Register MBean via Spring

From Dev

how to export spring task:executor as mbean?

From Dev

spring hibernate and caching using ehcache

From Dev

EHCache Configuration + Spring Boot: NoCacheRegionFactoryAvailableException

From Dev

cutom ehcache evict policy with spring

From Dev

cutom ehcache evict policy with spring

From Dev

Migrate ehcache:proxy to spring 4

From Dev

Spring Boot does not initialize Ehcache

From Dev

Configure JMX with Spring implementation of ehcache?

From Dev

Error initializing the application with Spring Security: net/sf/ehcache/Ehcache not found

From Dev

Configure read-only attribute for jmx mbean with xml spring configuration

From Dev

Spring, and Hibernate 2nd level with Ehcache

From Dev

Using EhCache in Spring 4 without XML

From Dev

Spring Cache with Ehcache @CacheEvict doesn't work

From Dev

Refreshing Caches while under load with Spring/EHCache

From Dev

Cannot get EHCache and Spring Boot to start up

From Dev

Ehcache Java Spring MVC and pagination @Cacheable

From Dev

Evict Ehcache elements programmatically, using Spring

From Dev

timetoliveseconds ehcache spring boot config is not working

Related Related

HotTag

Archive