0

I am using Spring 4.3.7, Hibernate 5.2.9, hibernate-jcache 5.2.10 and ehcache 3.3.1.

this is relevant JPA configuration properties:

 properties.put("hibernate.cache.use_second_level_cache", "true");
        properties.put("hibernate.cache.use_query_cache", "true");
        properties.put("hibernate.cache.region.factory_class", "org.hibernate.cache.jcache.JCacheRegionFactory");
        properties.put("hibernate.javax.cache.provider", "org.ehcache.jsr107.EhcacheCachingProvider");
        properties.put("hibernate.generate_statistics", "true");

I have configured L2 caching on my entities and queries.

In console log output I can see some caching is taking place. But I want to use jconsole to explore the statistics.

My question is how do I expose JMX statistics service of these package versions for jconsole to be able to render the stats?

All I have is:

@Bean
    public void ehCacheManager() {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory(Vedantas.PU_NAME);
        SessionFactory sf = emf.unwrap(SessionFactory.class);

        StatisticsService statsMBean = new StatisticsService();
        statsMBean.setSessionFactory(sf);
        statsMBean.setStatisticsEnabled(true);

        MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
        mBeanServer.registerMBean(statsMBean, new ObjectName("Hibernate:application=Statistics"));
    }

which is the Enable JMX support inside Hibernate - Using the API section from the jconsole documentation which doesn't really help because StatisticsService is an abstract class and cannot be instantiated.

So, please provide me some working configuration. Also, running java -jar hibernate-jconsole-1.0.7.jar does nothing in my environment. why is that so? Thanks!

Henri
  • 5,551
  • 1
  • 22
  • 29
greengold
  • 1,184
  • 3
  • 18
  • 43
  • You want Hibernate statistics right? Not cache statistics? – Henri May 29 '18 at 14:42
  • well, I want both. but have to admit I have migrated to Hazelcast which have a nice monitoring app cause this was very poorly documented and messed up with version change to 3.x so I may not be able to follow, but if you have something working you can post it for future reference i guess – greengold May 30 '18 at 05:51
  • On the cache side, when using JSR107, statistics are directly available in JMX. If you don't need clustered replication, Hazelcast is a bit overkill – Henri May 31 '18 at 15:07

0 Answers0