8 Replies Latest reply on Oct 4, 2005 8:03 AM by Darran Lofthouse

    Getting an "IllegalArgumentException" with RMIAdaptor in 3.2

    Steven Wood Newbie

      Hi,

      I'm trying to write a simple client to access the MBean for a JMS destination. Whenver I try and invoke a method on the RMIAdaptor I get an IllegalArgumentException claiming I've used the "wrong number of arguements"

      Can anyone help !? Here's the code :-

      Properties props = new Properties();

      props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.setProperty(Context.PROVIDER_URL, "jnp://ifdevdoc2:6999");
      InitialContext ctx = new InitialContext(props);

      RMIAdaptor server = (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor");
      ObjectName name = new ObjectName("jboss.mq.destination :name=THRequest");
      //error happens here..
      System.out.println(server.getAttribute(name, "JNDIName"));


      Thanks,
      Steve.

        • 1. Re: Getting an
          Vicky Kak Master

          Why is there space in "jboss.mq.destination :name=THRequest" , remove that and check the results ?
          Vicky

          • 2. Re: Getting an
            Steven Wood Newbie

            Still getting the same error :(

            • 3. Re: Getting an
              Darran Lofthouse Master

              There is a bit missing from your name, the following works fine on 4.0.2

               Properties props = new Properties();
              
               props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
               "org.jnp.interfaces.NamingContextFactory");
               props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
               InitialContext ctx = new InitialContext(props);
              
               RMIAdaptor server = (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor");
               ObjectName name = new ObjectName("jboss.mq.destination:name=A,service=Queue");
               // error happens here..
               System.out.println(server.getAttribute(name, "JNDIName"));


              • 4. Re: Getting an
                Steven Wood Newbie

                 

                Properties props = new Properties();
                
                 props.setProperty(
                 Context.INITIAL_CONTEXT_FACTORY,
                 "org.jnp.interfaces.NamingContextFactory");
                 props.setProperty(Context.PROVIDER_URL, "jnp://ifdevdoc2:6999");
                 InitialContext ctx = new InitialContext(props);
                
                 RMIAdaptor server = (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor");
                 ObjectName name = new ObjectName("jboss.mq.destination:name=THRequest,service=Queue");
                
                
                 //error here
                 System.out.println(server.getAttribute(name, "JNDIName"));


                I still get the same error. We're using JBoss 3.2.3 here, it may also be of note that if I try a method with no parameters e.g. "getDefaultDomain" it works fine. Using reflection determines that "getAttribute" has two parameters as well...

                • 5. Re: Getting an
                  Vicky Kak Master

                  try using
                  public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature)
                  throws InstanceNotFoundException, MBeanException, ReflectionException, IOException;

                  Vicky

                  • 6. Re: Getting an
                    Vicky Kak Master

                     

                    getAttribute
                    Object getAttribute(ObjectName name,
                     String attribute)
                     throws MBeanException,
                     AttributeNotFoundException,
                     InstanceNotFoundException,
                     ReflectionException,
                     IOExceptionGets the value of a specific attribute of a named MBean. The MBean is identified by its object name.
                    
                    Parameters:
                    name - The object name of the MBean from which the attribute is to be retrieved.
                    attribute - A String specifying the name of the attribute to be retrieved.
                    Returns:
                    The value of the retrieved attribute.
                    Throws:
                    AttributeNotFoundException - The attribute specified is not accessible in the MBean.
                    MBeanException - Wraps an exception thrown by the MBean's getter.
                    InstanceNotFoundException - The MBean specified is not registered in the MBean server.
                    ReflectionException - Wraps a java.lang.Exception thrown when trying to invoke the setter.
                     
                    RuntimeOperationsException - Wraps a java.lang.IllegalArgumentException: The object name in parameter is null or the attribute in parameter is null.
                    
                    IOException - A communication problem occurred when talking to the MBean server.
                    See Also:
                    setAttribute(javax.management.ObjectName, javax.management.Attribute)
                    

                    Emphasis on the underlined part to get the actual cause of the error you are getting .
                    Vicky

                    • 7. Re: Getting an
                      Steven Wood Newbie

                      Thanks for all your help ! Using that last suggestion I got an error that enabled me to find out it was due to having the wrong version of the javax.management classes on my client side.


                      many thanks,
                      Steve.

                      • 8. Re: Getting an
                        Darran Lofthouse Master

                        I have just tested the code I posted and it also works fine against 3.2.3.