Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
AppFuseSupport




JSPWiki v2.2.33

[RSS]


Hide Menu

HibernateJMX


Difference between version 21 and version 4:

At line 6 added 4 lines.
Note: Using JDK 1.5 with the JAVA_OPTS and JConsole is optional, most app servers
already have a MBean server, and MC4J (http://mc4j.sourceforge.net/) provides a JMX Console
for most of them.
At line 18 added 2 lines.
(Note: Under Windows, I started tomcat5w.exe and set the above properties in the Java
tab, in the textfield entitled 'Java Options').
At line 15 changed 1 line.
Inside StartupListener.java (inside contextInitialized method) add:
Then, if you are using Spring, add this to your applicationContext-hibernate.xml file:
At line 23 added 40 lines.
{{{
<bean id="jmxExporter"
class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="Hibernate:type=statistics">
<ref local="statisticsBean" />
</entry>
</map>
</property>
</bean>
<bean id="statisticsBean" class="org.hibernate.jmx.StatisticsService">
<property name="statisticsEnabled">
<value>true</value>
</property>
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
}}}
and then set the hibernate.generate_statistics property in your
applicationContext-hibernate.xml file:
{{{
<prop key="hibernate.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 Hibernate, if you double click on that node, you should see
the Statistics Bean.
Tomcat 5 already contains the MX4J libraries and your AppFuse project should
already have the Hibernate libraries in the runtime classpath. Below are a couple of screenshots.
<a href="http://raibledesigns.com/wiki/attach/HibernateJMX/hibernatestats1.png"><img src="http://raibledesigns.com/wiki/attach/HibernateJMX/hibernatestats1.png" width="300" style="margin-left: 20px"/></a> <a href="http://raibledesigns.com/wiki/attach/HibernateJMX/hibernatestats2.png"><img src="http://raibledesigns.com/wiki/attach/HibernateJMX/hibernatestats2.png" width="300" style="margin-left: 10px" /></a>
If you are not using Spring, inside StartupListener.java (inside contextInitialized method) add:

Back to HibernateJMX, or to the Page History.