Hibernate version: 3.2
In every example I've found, the StatisticsService is being used dynamically by a running system. I'm trying to add it to my jboss-service.xml, with
Code:
<mbean code="org.hibernate.jmx.StatisticsService" name="hibernate:name=StatisticsService">
<attribute name="SessionFactoryJNDIName">java:/dvsSessionFactory</attribute>
</mbean>
The problem is, the session factory doesn't exist when the jboss-service.xml file is parsed, and the attribute is set (i.e. the setSessionFactoryJNDIName() method is called).
In that method, the code looks like this:
Code:
public void setSessionFactoryJNDIName(String sfJNDIName) {
this.sfJNDIName = sfJNDIName;
try {
Object obj = new InitialContext().lookup(sfJNDIName);
.
.
.
IMO, the lookup should not be done when the setter is called, because the MBean hasn't started yet. The value should only be stored for later use. When the MBean gets started, that's when the lookup should happen.
Am I wrong?
BTW, I can add this as an MBean without the attribute being set, and set the value in the JMX Console, but I have to put in the SessionFactory name.