2 Replies Latest reply on Jan 3, 2011 12:57 PM by aflopes

    MBean in JBoss AS 3.2.7

    aflopes

      Hi all,

       

      I'm working on an application that is deployed in a JBoss AS 3.2.7 for almost 4 years in a production environment. This application have a MBean that is configured in the deploy/user-service.xml file:

      <mbean code="com.company.mbean.AppInit" name=":service=AppInit"></mbean>

       

      The classes of this MBean are in a jar file located in the lib folder and are the following:

       

      Interface AppInitMBean:

       

      package com.company.mbean;

      public interface AppInitMBean {

        public abstract void init() throws Exception;

        public abstract void start() throws Exception;

        public abstract void stop() throws Exception;

        public abstract void destroy() throws Exception;

        public abstract void printSessions();

      }

       

       

      Class AppInit:


      package com.company.mbean;

      import javax.management.MBeanRegistration;

       

      public class AppInit implements MBeanRegistration, AppInitMBean{

       

      /* @see javax.management.MBeanRegistration#preRegister(javax.management.MBeanServer, javax.management.ObjectName) */

      public ObjectName preRegister(MBeanServer server, ObjectName name) throws java.lang.Exception {

      return new ObjectName(":service=AppInit");

      }

       

      /* @see javax.management.MBeanRegistration#postRegister(java.lang.Boolean)*/

      public void postRegister(java.lang.Boolean registrationDone) {}

       

      /* @see javax.management.MBeanRegistration#preDeregister()*/

      public void preDeregister() throws java.lang.Exception { }

       

      /* @see javax.management.MBeanRegistration#postDeregister()*/

      public void postDeregister() {}

       

      public void init() throws Exception {...}

      public void start() throws Exception {...}

      public void stop() throws Exception {...}

      public void destroy() throws Exception {/*do nothing*/}

      public void printSessions(){...}

      }

       

       

      With this settings the method start() is invoked when the JBoss starts, but now i want to make a new MBean that depends on a class that is initialized in the described MBean. I've tried to make it similar to the AppInit MBean, but the start method is never invoked.

       

      Why JBoss invoke the start method for one MBean and not for the other? The differences between them is their name and the jar file that contains the respective classes. The configuration of the new one is:

       

      <mbean code="com.company.control.Control" name=":service=Control"></mbean>

       

      Did i miss some configuration?

       

      I know the structure and configuration of this MBeans is probably not the best one (didn't find any thing on the net saying to do things this way) but is the one i have, and i will have to live with it (unfortunately).

       

       

        <mbean code="wedo.sussd.ejb.mbean.Sussd" name=":service=Sussd">
        </mbean>

       

        • 1. Re: MBean in JBoss AS 3.2.7
          jaikiran

          I'm not sure what might be wrong. But try narrowing it down:

           

          1) Is the new MBean defined in a *-service.xml file? Where exactly is that file (or the jar containing the *-service.xml) placed?

          2) Try adding the new MBean in the same jar as the old MBean

          • 2. Re: MBean in JBoss AS 3.2.7
            aflopes

            Hi jaikiran

             

            I have already solved this problem defining both MBeans in the deploy/user-service.xml file:

             

            <mbean code="com.company.control.Control" name="app:service=Control">

                <depends>

                      <mbean code="com.company.mbean.AppInit" name="app:service=AppInit"></mbean>

                </depends>

            </mbean>

             

            With this configuration, the AppInit MBean starts before the Control MBean.

             

            Regarding your sugestions, the file is deploy/user-service.xml, and for classpath reasons is not possible to put both MBeans in the same jar file.

             

            Thanks for your help anyway!