使用 JConsole 监控 c3p0(使用 hibernate 和 Tomcat)
Web 应用程序是一个 Struts 应用程序(无 spring),使用 c3p0 和 Hibernate,位于 Tomcat 6 中。Hibernate 和 c3p0 jar 都位于 {WEB_APP}/WEB-INF/lib 文件夹中。
在 Tomcat 中启用 jmx 远程: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
当我使用 jconsole 连接到它时,我在选项卡中看不到 c3p0 MBean。
我需要在 Tomcat 或 Web 应用程序中进行任何配置吗?
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您不使用 Spring 或 JBoss 时,当涉及到 Hibernate 的 JMX 监控时,需要更多的动手操作。
您需要执行以下操作:
在 Hibernate 配置中添加:
然后在应用程序的启动部分中,您需要向 MBean 服务器注册 MBean:
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName objectName = new ObjectName("org.hibernate:type=statistics");
统计服务 mBean = 新的统计服务();
mBean.setStatisticsEnabled(true);
mBean.setSessionFactory(sessionFactory);
mbeanServer.registerMBean(mBean, objectName);
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:
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);