2014-04-25 8 views
6

스프링 4.0.3.RELEASE 및 EHcache 2.8.1을 사용하고 있습니다. JBoss 7.1.1에서스프링 Ehcache MBean 모니터링

applicationContext.xml에서 다음 구성을 사용하면 캐싱이 잘 작동합니다.

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

이제 모니터링 기능을 MBean에 추가하려고합니다. applicationContext.xml의 설정을 다음과 같이 변경했습니다. - 2 개의 새로운 bean "managementService"와 "mbeanServer"를 추가했습니다. 다른 변경 사항은 없습니다. 이것은 현재 구성입니다.

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

이 구성을 사용하면 응용 프로그램 서버 시작시 다음 오류가 발생합니다.

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

mbean 물건을 제거하고 ''로 바꾸십시오. – geoand

답변

6

당신은 managementService 콩하지 cacheManager의 생성자에 ehcache 빈을 통과해야한다. cacheManager의 정의를 보면 ehcache 콩은 cacheManager으로 전달됩니다. 팩토리 빈은 net.sf.ehcache.CacheManager의 인스턴스를 제공합니다.