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!