8 Replies Latest reply on Jul 30, 2002 1:14 AM by sgturner

    JBoss 3.0 JMX java.lang.NoSuchMethodException

    dfunkt

      hello all,

      i am having some difficulty moving an existing JBoss 2.2 application to JBoss 3.0. currently, i am receiving a ReflectionException with a java.lang.NoSuchMethodException as its root cause. the offending code seems to be the following:

      String[] types = (String[]) server().invoke("DefaultDomain:service=Register,jndiName=CFRegistry", "getManagedTypes", new Object[0], new String[0]);

      when the test client runs, i get the following message serverside:

      18:03:03,174 ERROR [STDERR] ReflectionException: null
      Cause: java.lang.NoSuchMethodException: Unable to locate method for: getManagedT
      ypes()
      18:03:03,174 ERROR [STDERR] at org.jboss.mx.capability.ReflectedMBeanDispatc
      her.invoke(ReflectedMBeanDispatcher.java:288)
      18:03:03,184 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
      eanServerImpl.java:491)
      18:03:03,184 ERROR [STDERR] at com.eidea.svc.ejb.componentfactory.ComponentF
      actoryBean.getManagedTypes(ComponentFactoryBean.java:228)
      ...


      i have added the following debugging code:

      ObjectInstance objectInstance = server().getObjectInstance("DefaultDomain:service=Register,jndiName=CFRegistry");
      System.out.println("objectInstance.className = " + objectInstance.getClassName());


      which causes the following output:

      18:03:03,174 INFO [STDOUT] objectInstance.className = com.eidea.svc.jmx.register.Register

      this output indicates to me that there is indeed an MBean available, which DOES have the 'getManagedTypes' method with no parameters. why can't this method be found??? it evidently worked in version 2.2 of JBoss. i read somewhere in these forums that there is a problem with the JMX implementation from Sun, could this be the source of the problem? any help would be GREATLY appreciated! i am out of ideas here...

      thanks!

        • 1. Re: JBoss 3.0 JMX java.lang.NoSuchMethodException
          sgturner

          This happened to me. It turned out that the method is being looked up by not only the name, but the signature. Your code indicates that the signature of the method is empty by the fact that your code uses newObject[0], new String [0]. I suggest you try passing null for both those values in the invoke method. If it worked in 2.2, but not in 3.0, I would chalk that up to JBoss having a better implementation of JMX in 3.0.

          • 2. Re: JBoss 3.0 JMX java.lang.NoSuchMethodException
            dfunkt

            thanks for the help senor turner!

            unfortunately, that didn't work for me. i tried changing the parameters passed in to null, as well as setting their values to null. neither tactic worked. ??? i am using JBoss 3.0.0 (current when i started this little migration journey...) if that info is any help.

            thanks again for any help/advice!...

            • 3. Re: JBoss 3.0 JMX java.lang.NoSuchMethodException
              sgturner

              <i tried changing the parameters passed in to null, as well as setting their values to null>

              I'm confused what the difference is.

              The code should be:
              server().invoke("DefaultDomain:service=Register,jndiName=CFRegistry","getManagedTypes",null, null);

              Does your MBean and method appear in 8082?

              The only other thing I know to do is take the bitter pill and go in there with the debugger and see whats happening.

              • 4. Re: JBoss 3.0 JMX java.lang.NoSuchMethodException
                dfunkt

                a little sleight of hand there, sorry! i condensed and 'paraphrased' the code... in actuality, the code declares 2 local array variables, which are the parameters passed in, and then calls invoke( ) with the references. i tried commenting out the original invoke( ) call, and replaced it with an invoke( ) with nulls as parameters and not the variables. didn't work... so i then tried setting the references to null (instead of the empty arrays) when they are declared, and then using the original method call. LONG shot, and again no dice.

                the MBean does indeed appear in the agent view, but when i click on it to view it, only a small subset of the methods appear. it shows the MBean lifecycle callback methods, and a single business method. everything else is nowhere to be seen. (evidently the root of the problem...)

                i assume you mean getting in the JBoss code with the debugger... sounds interesting, if a bit scary. thanks for the excellent and prompt help and advice! =) i am new to this project, as well as JBoss, and it has really been quite a learning process.

                i am also going to try casting the MBean reference, and calling the method explicity rather than with reflection. someone in our meeting this morning suggested that we could do this. well, at leaast i have a couple different options now...

                peace, doug

                • 5. Re: JBoss 3.0 JMX java.lang.NoSuchMethodException
                  sgturner

                  < going to try casting the MBean reference>

                  If you mean casting the ObjectInstance, that won't work since ObjectInstance is not in the class hierarchy of your MBean.

                  If things don't look right in the agent view, then fix that first. Go method by method, making sure correct pattern is followed for setters and getters, and method name in interface matches method name in class. Shut down JBoss and delete tmp directory.

                  • 6. Re: JBoss 3.0 JMX java.lang.NoSuchMethodException
                    dfunkt

                    i just figured that out...i was thinking objectInstance was an instance of Object. doh! =(

                    ok. will try your suggestions. gracias!

                    • 7. Re: JBoss 3.0 JMX java.lang.NoSuchMethodException

                      You need to use server.getAttribute("AttributeName") to read an attribute value rather than server.invoke() which only works for operations.

                      -- Juha

                      • 8. Re: JBoss 3.0 JMX java.lang.NoSuchMethodException
                        sgturner

                        Nothing like getting the right answer from the master !! Thanks Juha.