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

    Dynamically Register an MBean

    Pooja Chauhan Newbie


      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.