Apr 26 2009

Hibernate statistics on Tomcat with JMX

Published by Gilles at 5:00 pm under Hibernate, J2EE, Java

This little snippet will show you how to get Statistics JMX MBean available.

Inside the tomcat startup script (bin/tomcatXw.exe), ensure that the following _OPTS are set:

JAVA_OPTS="
-Dcom.sun.management.jmxremote.port=9002
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.awt.headless=true"

In your config, add:

XML:
  1. <bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter"></bean>
  2.  
  3. <property name="beans">
  4. <map>
  5.     <entry key=":name=statistics">
  6.      <ref local="statisticsBean"/>
  7. </entry>
  8. </map>
  9. </property>
  10. <bean id="statisticsBean" class="org..jmx.StatisticsService"/>
  11. <property name="statisticsEnabled"><value>true</value></property>
  12. <property name="sessionFactory"><ref local="sessionFactory"></ref></property>

and then set the .generate_statistics property:

XML:
  1. <prop key=".generate_statistics">true</prop>

When you browse the MBeans (using JConsole.exe - which lives in the bin dir of your JDK 1.5 distribution), you should see , if you double click on that node, you should see the Statistics Bean.

Trackback URI | Comments RSS

Leave a Reply