Bug 743662
Summary: | Hibernate Statistics plugin does not support JBoss EWS | ||
---|---|---|---|
Product: | [Other] RHQ Project | Reporter: | Richard Robinson <rrobinso> |
Component: | Plugins | Assignee: | Nobody <nobody> |
Status: | NEW --- | QA Contact: | |
Severity: | unspecified | Docs Contact: | |
Priority: | medium | ||
Version: | 3.0.1 | CC: | hrupp |
Target Milestone: | --- | Keywords: | FutureFeature |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Enhancement | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | Type: | --- | |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Richard Robinson
2011-10-05 16:38:24 UTC
Richard, you say that by adding a line of <parent-resource-type name="TomcatServerComponent" plugin="Tomcat"/> You got that to run? Is above the correct type ('TomcatServer' as you wrote in the description seems not existent)? Heiko Hello Heiko, The above configuration was surmise, based on the pattern seen in the configuration with other parent-resource-type. It didn't work. I *did* finally get hibernate statistics to work, however, in Tomcat/Jboss EWS by adding the below included class and calling it in a static method or block in one of the start up classes in our application (war). I believe the code below comes straight out of the docs (somewhere) with minor modifications. <code> public class HibernateStatistics { private static final Logger LOG = Logger.getLogger(HibernateStatistics.class); private static final String HIBERNATE_STATISTICS_MBEAN_OBJECTNAME = "Hibernate:application=hibernateStatistics,type=statistics"; private static boolean enabled = false; public static void enableHibernateStatistics(final EntityManager entityManager) { if (enabled) { return; } try { final StatisticsService mBean = new StatisticsService(); final SessionFactory sessionFactory = getHibernateSession(entityManager).getSessionFactory(); mBean.setSessionFactory(sessionFactory); final ObjectName objectName = new ObjectName(HIBERNATE_STATISTICS_MBEAN_OBJECTNAME); final MBeanServer jbossMBeanServer = getJBossMBeanServer(); jbossMBeanServer.registerMBean(mBean, objectName); LOG.info("About to enable Hibernate statistics..."); sessionFactory.getStatistics().setStatisticsEnabled(true); LOG.info("Hibernate statistics have been enabled."); } catch (final InstanceAlreadyExistsException iaee) { LOG.info("Duplicate MBean registration ignored: " + HIBERNATE_STATISTICS_MBEAN_OBJECTNAME); } catch (final Exception e) { LOG.warn("Couldn't register Hibernate statistics MBean.", e); } enabled = true; } private static Session getHibernateSession(final EntityManager entityManager) { Session session; if (entityManager.getDelegate() instanceof EntityManagerImpl) { final EntityManagerImpl entityManagerImpl = (EntityManagerImpl) entityManager.getDelegate(); session = entityManagerImpl.getSession(); } else { session = (Session) entityManager.getDelegate(); } return session; } private static MBeanServer getJBossMBeanServer() { final List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null); MBeanServer jbossServer = null; for (final MBeanServer server : servers) { if ("jboss".equals(server.getDefaultDomain())) { jbossServer = server; } } if (jbossServer == null) { jbossServer = ManagementFactory.getPlatformMBeanServer(); } return jbossServer; } </code> |