开发者

Monitor c3p0 (with hibernate and Tomcat) with JConsole

The Web App is a Struts application (no spring) using c3p0 with Hibernate and it's in Tomcat 6. Both Hibernate and c3p0 jars are in the {WEB_APP}/WEB-INF/lib folder.

In Tomcat the jmx remote is enabled: -Dcom.sun开发者_运维技巧.management.jmxremote -Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false

When I use jconsole connecting to it, I do not see the c3p0 MBean in the tab.

Is there any configuration I need to do in Tomcat or the web app?

Thanks!


When you are not using Spring or JBoss then things are a little more hands on when it comes to JMX monitoring of Hibernate.

You need to do the following:

  • In your Hibernate Configuration add:

    <property name="hibernate.generate_statistics">true</property>
    
  • Then in a startup segment of your app you need to register the MBeans with the MBean server:

    MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); ObjectName objectName = new ObjectName("org.hibernate:type=statistics"); StatisticsService mBean = new StatisticsService(); mBean.setStatisticsEnabled(true); mBean.setSessionFactory(sessionFactory); mbeanServer.registerMBean(mBean, objectName);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜