2014-04-25 18 views
6

Tôi đang sử dụng Spring 4.0.3.RELEASE và EHcache 2.8.1. trên JBoss 7.1.1Giám sát MBc mùa xuân Ehcache

Với cấu hình sau trong applicationContext.xml bộ nhớ đệm của tôi hoạt động tốt.

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

Bây giờ tôi muốn thêm khả năng giám sát với MBean. Tôi đã thay đổi cấu hình trong applicationContext.xml như sau - thêm 2 bean mới “managementService” và “mbeanServer”, không có thay đổi nào khác. Đây là cấu hình hiện tại.

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

Với cấu hình này, tôi gặp lỗi sau khi khởi động máy chủ ứng dụng.

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

Hãy thử loại bỏ công cụ mbean của bạn và thay thế bằng '' – geoand

Trả lời

6

Bạn nên vượt qua đậu ehcache đến constructor của managementService đậu không cacheManager. Nếu bạn nhìn vào định nghĩa của cacheManager hạt đậu ehcache được chuyển thành cacheManager. Đậu của nhà máy sẽ cung cấp một phiên bản net.sf.ehcache.CacheManager.