java -Dcom.sun.management.jmxremote.port=19988 \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -jar helloworld.jar
Name |
Hibernate |
Description |
Provides monitoring of Hibernate session manager statistics, EJB3 entities and queries |
RHQ Version |
1.0 |
View Source |
|
Get Source |
The Hibernate plugin provides monitoring capabilities for Hibernate session manager, EJB3 entities and queries.
The monitoring is possible in any JVM that has the remote JMX monitoring enabled. To enable JMX monitoring, start your JVM using command line parameters such like:
java -Dcom.sun.management.jmxremote.port=19988 \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -jar helloworld.jar
In addition, you have to manually enable Hibernate statistics MBean in the code of your application like this:
StatisticsService mBean = new StatisticsService(); SessionFactory sessionFactory = //...get hibernate session factory... mBean.setSessionFactory(sessionFactory); ObjectName objectName = new ObjectName("Hibernate:application=MY_APP_NAME,type=statistics"); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.registerMBean(mBean, objectName); sessionFactory.getStatistics().setStatisticsEnabled(true);
Once this setup is in place, you can point the Hibernate plugin to the host and port of the MBean server (configured by the command line parameters above) and you should see the Hibernate statistics of your application listed in the RHQ user interface.