Simon B Simon B - 1 year ago 135
Java Question

running Hibernate 4.3 with JMX (without spring)

I'm running a java webapp (wicket 6.13) using Hibernate 4.3 and Guice 1.0

I'm trying to configure Hibernate so that I can access runtime information via the JMX framework.

I'm not using spring, can anyone indicate how I enable the JMX on hibernate 4.3 manually.

I've poked around the JmxService, JmxServiceInitiator, JmxServiceImpl, StandardServiceRegistryImpl

I've also found the following settings in AvailableSettings:


I've added the jmx.enabled true setting to my hibernate.cfg.xml file but this has had no effect.

I'm still not sure how to go about this.

Any help much appreciated

Answer Source

seems to be a bug after refactoring in hibernate. see for details

Here's a workaround I've used, utilising a java dynamic proxy to represent the statistics interface from hibernate, and the default platform mbean server:

public interface StatisticsMXBean extends Statistics {

public void initStatistics(SessionFactory sessionFactory) {
    ObjectName statsName = new ObjectName("org.hibernate:type=statistics");
    MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();

    final Statistics statistics = sessionFactory.getStatistics();
    Object statisticsMBean = Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[] { StatisticsMXBean.class }, new InvocationHandler() {

            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                return method.invoke(statistics, args);

    mbeanServer.registerMBean(statisticsMBean, statsName);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download