2014-04-25 16 views
6

Ich verwende Spring 4.0.3.RELEASE und EHcache 2.8.1. auf JBoss 7.1.1Frühjahr Ehcache MBean Überwachung

Mit der folgenden Konfiguration in applicationContext.xml funktioniert mein Caching gut.

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

Jetzt möchte ich die Überwachungsfunktionen mit MBean hinzufügen. Ich habe die Konfiguration in applicationContext.xml wie folgt geändert - hinzugefügt 2 neue Beans "ManagementService" und "mbeanServer", keine andere Änderung. Dies ist die aktuelle Konfiguration.

Mit dieser Konfiguration bekomme ich den folgenden Fehler beim Start des Anwendungsservers.

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

Versuchen Sie, mbean sachen zu entfernen, und ersetzen Sie es mit '' – geoand

Antwort

6

Sie sollten die ehcache Bohne an den Konstruktor der managementService Bohne nicht cacheManager passieren. Wenn Sie die Definition von cacheManager betrachten, wird die ehcache Bean als cacheManager übergeben. Die Factory-Bean stellt eine Instanz von net.sf.ehcache.CacheManager bereit.