Question

I am working on migrating project from JBoss 4.2.2 to JBoss 7.1.1. We had Configuration MBean and other beans on start were connecting to this Configuration MBean to get some parameters. So jboss-service.xml configuration was like that:

    <mbean code="example.ConfigManager" name="exam:name=ConfigManager">        
         <attribute name="DataSourceName">java:jboss/datasources/myDS</attribute>
    </mbean>
...
    <mbean code="example.AnotherMBean" name="exam:name=AnotherMBean">
         <depends>exam:name=ConfigManager</depends>
         <attribute name="Login">system</attribute>
    </mbean>

In jboss 7 I have implemented MBeans in the way it is required (implemented start() and stop() method), but when starting AnotherMBean and it is trying to get information from ConfigManager I get:

javax.management.InstanceNotFoundException: exam:name=ConfigManager

There are no problems with ConfigManager, it simply loads after AnotherMbean. Is it possible to define loading order for MBeans?

P.S. Don't advise switching to @Startup and @Singleton, it is not possible for now, due to our system requirements.

Thank you!

Was it helpful?

Solution

So, no workaround was found, so reconfigured my application to use Singleton ejbs with @DependsOn annotations. And in @PostConstruct method created something like

    @PostConstuct 
    private void registerToJMX() {
       private MBeanServer platformMBeanServer;
       private ObjectName objectName = null;
       try {
           objectName = new ObjectName("tms:name=BlankNotifications");
           platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
           platformMBeanServer.registerMBean(this, objectName);
       } catch (Exception e) {            
       }
    }

To register it in JMX console.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top