2014-04-25 11 views
6

Sto usando Spring 4.0.3.RELEASE ed EHcache 2.8.1. su JBoss 7.1.1Spring Ehcache MBean Monitoring

Con la seguente configurazione in applicationContext.xml, la memorizzazione nella cache funziona correttamente.

<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> 

Ora voglio aggiungere le funzionalità di monitoraggio con MBean. Ho modificato la configurazione in applicationContext.xml come segue: aggiunto 2 nuovi bean "managementService" e "mbeanServer", nessun'altra modifica. Questa è la configurazione corrente.

<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> 

Con questa configurazione viene visualizzato il seguente errore all'avvio del server delle applicazioni.

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 
+0

Provare a rimuovere i file mbean e sostituirli con '' – geoand

risposta

6

Si dovrebbe passare il fagiolo ehcache al costruttore del managementService fagioli non cacheManager. Se si guarda la definizione di cacheManager il bean ehcache viene passato come cacheManager. Il bean factory fornirà un'istanza di net.sf.ehcache.CacheManager.