2 Replies Latest reply on Jun 7, 2004 10:59 AM by raja05

    Dynamically Register an MBean

    poojac20

      Hi

      I looked at an example of MBean, which deploys an EJB and the main () function from the MBean class registers the MBean. Ofcourse hence u first need to run that program from command prompt. Then the MBean is available.

      Taking inspiration from the example, I copied the code to register the MBean inside my InitServlet (the servlet which loads on start-up)
      Its a test MBean, only one getter in it.

      public int getNumber () {
      return 100;
      }
      
      
      This is the code written in initServlet.
      
      MBeanServer server = MBeanServerFactory.createMBeanServer();
      ObjectName on = new ObjectName ("NovaDomain", "Name", "TerminalChangeMgrMBean");
      TerminalChangeManager mgr = new TerminalChangeManager ();
      server.registerMBean(mgr, on);
      
      
      
      The code runs without exception but I still do not see this MBean listed on jmx-console. I am trying it for the first time, so may be that is not what shud be expected.
      
      Anything I am missing?
      Thanx in advance for the answer.
      --- Pooja. 
      
      
      
      


        • 1. Re: Dynamically Register an MBean
          poojac20

          hey guys!

          sorry for the mess in the post, I never saw the code tag and hence typed it manually. didn't know they were invisible ;)

          hope nobody minds it so much.
          --- Pooja.

          • 2. Re: Dynamically Register an MBean
            raja05

            Why are you trying to create a mbeanserver when there is one already available inside jboss? Use the RMIAdaptor to get an instance of adaptor and register ur servlet to the mbean server implementation stored at :JMImplementation:type=MBeanServerDelegate