2 Replies Latest reply on Jul 12, 2002 12:50 PM by adrian.brock

    RemoteMBeanServer.createMBean() returns null - but no except

    ctoomey

      Hi,
      I've spent a couple of hours looking for an answer to this
      one, maybe somebody can spot my (probably obvious) mistake
      - I am new to jboss.

      Got a reference to RemoteMBeanServer using RMI-Adaptor.
      Now I try to create/register/start an MBean using:

      ObjectName objName=ObjectNameFactory.create(...);
      ObjectInstance obj=server.createMBean(className,objName);

      createMBean() returns null, but does not throw an
      exception - the javadocs imply that a null return value
      is not allowed.

      Does anybody have any idea what I've done wrong here?
      Or where I can look to see what is happening?
      Thanks in advance for any help,
      Colm

        • 1. Re: RemoteMBeanServer.createMBean() returns null - but no ex

          This could be a bug somewhere in the code.

          I don't have to time to go and search for it in detail right now, however a quick glance at the BasicMBeanRegistry.java (org.jboss.mx.server.registry package) reveals that a null is returned in a case where an unexpected error is encountered by the registry (lines below, don't have the exact line numbers as the version I'm looking at has been modified quite a bit):



          catch (Throwable t)
          {
          // Some other error
          registrationDone = false;
          return null;
          }


          (sorry for the formatting, forums are still not quite working right).


          You could try to edit this and see if this is where you're getting your null from. At least we should have a log.warn() or log.error() here. I think we probably should also throw a RuntimeOperationsException here rather than null.

          Adrian any comments?

          -- Juha

          • 2. Re: RemoteMBeanServer.createMBean() returns null - but no ex

            I agree with your analysis. Providing it is not the
            connector/adaptor returning null.

            In principle, that code should be unreachable.

            Although it could happen if preRegister throws an Error.
            But in that case you'll get a warning logged.

            Logging the original throwable and throwing a
            RuntimeOperationsException would
            give more information in finding this problem.

            Regards,
            Adrian