5 Replies Latest reply on Sep 13, 2002 7:49 AM by juha

    Reflection Error with MBeanServer Invoke

    Mike Cahill Newbie

      Hi All,

      Can anyone tell me what I have missed to cause the following exception? The exception is:-

      [ERROR,Default] javax.management.ReflectionException: The operation with name addManager could not be found

      The call to invoke is:
      Object[] arr = {new LogManager()};
      Object result = mbs.invoke(obn, "addManager", arr, null);

      where I know a bean with a valid object name (obn) is already registered.

      and my method on the MBean is
      public void addManager(LogManager m);

      There must be something obvious I am missing.

      Thanks alot


        • 1. Re: Reflection Error with MBeanServer Invoke
          Adrian Brock Master

          You haven't defined your signature.

          Object[] arr = {new LogManager()};
          String[] sig = {LogManager.class.toString()};
          Object result = mbs.invoke(obn, "addManager", arr, sig);


          • 2. Re: Reflection Error with MBeanServer Invoke

            yeah you're missing the signature in your invoke() method (the last 'null' arg)

            So its trying to invoke addManager() not addManaged(LogManager)

            • 3. Re: Reflection Error with MBeanServer Invoke
              Mike Cahill Newbie

              To quote Homer Simpson "Doh!". Thanks guys, I knew it was something obvious.


              • 4. Re: Reflection Error with MBeanServer Invoke
                Mike Cahill Newbie

                Thanks for the responses guys. I am now facing a 'parameter class could not be found' error. I am assuming this is because my class, LogManager only exists in my ear file (both in a jar and a war in the ear) and is not on the classpath and therefore not available to the classloader used in the MBeanServer.

                Maybe if I explain what I am trying to achieve, somebody can guide me as to the best way to accomplish that.

                I would like my app to be self-contained in a single ear file. This includes any MBeans that may be needed for monitoring, management etc. I want my app to register its MBeans as it starts up so it can just be depoyed with no external dependancies.

                So as you may have guessed, I have a log manager and I want it to be managed via JMX. No big deal so far. However the log manager class is reused in both my war file and a jar file so there are two instances of it loaded up. I want both instances to be managed by the same MBean so I can switch off all logging hence my code to have the LogManagers register themselves with the existing MBean. Which leads to the problem stated above.

                Is there a way to have classes register themselves with a central MBean for management as they come up but without the classes beaing available on the classpath?

                Hope that makes sense and thanks in advance


                • 5. Re: Reflection Error with MBeanServer Invoke

                  You need to package your MBeans and ears and wars into a JBoss SAR (service archive) format. See the 'Getting Started' guide for details.

                  -- Juha