I'm having some trouble to get the Hibernate statistics MBean deployed correctly in my jboss instance.
The MBean does a lookup of the session factory the moment the setter for the SessionFactoryJNDIName is called, but at that time the persistence unit it depends on is not yet deployed. This means the hibernate statistics mbean is not initialized properly.
This is from the *-service.xml (which I have put in the ear file):
Code:
<mbean code="org.hibernate.jmx.StatisticsService"
name="Hibernate:application=myApplication,type=statistics">
<attribute name="StatisticsEnabled">True</attribute>
<attribute name="SessionFactoryJNDIName">mySessionFactory</attribute>
<depends>persistence.units:ear=myproject.ear,jar=myproject-ejb.jar,unitName=myPersistenceUnit</depends>
</mbean>
The jboss debug logging at startup shows:
Code:
{org.jboss.system.ServiceConfigurator} - SessionFactoryJNDIName set to mySessionFactory in Hibernate:application=myApplication,type=statistics
{org.hibernate.jmx.StatisticsService} - No session factory with JNDI name mySessionFactory
javax.naming.NameNotFoundException: mySessionFactory not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
but this is logged before the persistence unit is deployed. After the persistence unit is deployed, the logs show that the hibernate statistics service is started. I would have expected the jndi lookup of the SessionFactory to be done at this time rather than when setting the jndi name on the statistics mbean.
Can anyone help me with how to get this deployed properly?
I guess I could wrap the hibernate mbean in my own mbean and only set the jndi name of the session factory when the mbean is started, but I figure there must be a better way.
Thanks in advance!