>If you can get it to work, we should probably
>create a page in the 2.x wiki.

I've succeeded in a freshly new created project, by modifying the following two
files:

- src/main/resources/applicationContext-dao.xml
- src/main/resources/hibernate.cfg.xml

In the first file I've added (just before the comment " If you want to be able
to do simple CRUD...") the following :

================================================================
<bean id="jmxExporter"
        class="org.springframework.jmx.export.MBeanExporter">
        <property name="beans">
            <map>
                <entry key="Hibernate:name=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="sessionFactory" />
    </bean>
================================================================

In the second file, in the <session-factory> tag, just before the mappings I've
added:
<property name="hibernate.generate_statistics">true</property>

Then, once "mvn jetty:run-war" started the server, I could see with jconsole a
Hibernate MBean; please note that my project uses Java 6, but I presume that
nothing prevents Java 5 to expose the same behaviour.

For Tomcat, I had to add the options "-Dcom.sun.management.jmxremote.port=9002
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false" - however, no
"-Djava.awt.headless=true" was required in order to have the Hibernate MBean.

Marian


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net

Reply via email to