deepak asai
deepak asai

Reputation: 232

Monitoring cache date in Ehcache using JMX and Jconsole

I am using JMX approach for visualizing cache data that is stored using Ehcache in Spring web project. Whenever I click on getCache() method in Jconsole I am getting an error which is attached below. Could someone help me out with it? Thanks in advance

clicking on getCache() with the cache name as param

error message

Config File:

@Configuration
@EnableCaching
public class SpringCachePocConfig implements CachingConfigurer {

    net.sf.ehcache.CacheManager newCacheManager;

    @Bean(destroyMethod = "shutdown")
    public net.sf.ehcache.CacheManager ehCacheManager() {
        //Construct you cache here.

        net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
        config.addCache(<Your cache>);

        this.newCacheManager = new net.sf.ehcache.CacheManager(config);
        return newCacheManager;
    }


    @Bean
    public ManagementService managementService() {
        return new ManagementService(ehCacheManager(), mbeanServer(), true, true, true, true);

    }


    @Bean
    @Override
    public CacheManager cacheManager() {
        return new EhCacheCacheManager(ehCacheManager());
    }


    @Bean
    public MBeanServer mbeanServer() {
        MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
        return mBeanServer;   
    }

    @PostConstruct
    public void init() {
        ManagementService.registerMBeans(ehCacheManager(), mbeanServer(), true, true, true, true);
    }


}

Upvotes: 0

Views: 1158

Answers (1)

Ramesh Subramanian
Ramesh Subramanian

Reputation: 1037

You have to add the ehcache jar file (& its supporting jar files,if any) on the jconsole classpath like jconsole.exe -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;<<ehcache.jar>>. This will resolve the java.rmi.UnmarshalException when invoking such operations from the tool - JConsole

Upvotes: 1

Related Questions