1 Reply Latest reply on Jun 29, 2004 6:21 PM by Chris Buckley

    RemoteAdaptor - invoke(ObjectName, String, Object[], String[

    Chris Buckley Newbie

      Hello,

      I am trying to use the invoke method from the RemoteAdaptor, I can get it to work if I call an MBean method that takes no parameters like follows.
      // The connection URL.
      String endpoint = "http://roosevelt/jboss-net/services/RemoteAdaptor";

      Service service = new Service();
      Call call = (Call) service.createCall();
      call.setTargetEndpointAddress( new java.net.URL(endpoint) );
      //call.setOperationName("getDefaultDomain");
      //System.out.println("Default Domain: "+ call.invoke( new Object[]{}));

      QName qn = new QName("http://net.jboss.org/jmx", "ObjectNameType");
      call.registerTypeMapping(ObjectName.class, qn,
      new ObjectNameSerializerFactory(ObjectName.class, qn),
      new ObjectNameDeserializerFactory(ObjectName.class, qn));

      call.setOperationName("invoke");
      Object info = call.invoke(new Object[]{
      new ObjectName("jnms.test:service=HibernateTest"),
      new String("runGetAllTest"),
      new Object[]{},
      new String[]{}
      });
      //call.setOperationName("getMBeanCount");
      //Object info = call.invoke(new Object[]{});

      System.out.println("Info: "+info);


      However if I have a void method that takes a String argument I get an error, here is how I try to a use the "invoke" method and the error.

      Code: // The connection URL.
      String endpoint = "http://roosevelt/jboss-net/services/RemoteAdaptor";

      Service service = new Service();
      Call call = (Call) service.createCall();
      call.setTargetEndpointAddress( new java.net.URL(endpoint) );
      //call.setOperationName("getDefaultDomain");
      //System.out.println("Default Domain: "+ call.invoke( new Object[]{}));

      QName qn = new QName("http://net.jboss.org/jmx", "ObjectNameType");
      call.registerTypeMapping(ObjectName.class, qn,
      new ObjectNameSerializerFactory(ObjectName.class, qn),
      new ObjectNameDeserializerFactory(ObjectName.class, qn));

      call.setOperationName("invoke");
      Object info = call.invoke(new Object[]{
      new ObjectName("jnms.test:service=HibernateTest"),
      new String("runCreateObjectAndChildTxTest"),
      new Object[]{"test"},
      new String[]{"String"}
      });
      //call.setOperationName("getMBeanCount");
      //Object info = call.invoke(new Object[]{});

      System.out.println("Info: "+info);
      }




      Error:
      AxisFault
      faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
      faultSubcode:
      faultString: Problems while interfacing JMX.; nested exception is:
      MBeanException: ReflectionException: null
      Cause: java.lang.IllegalArgumentException: Unable to find operation runCreateObjectAndChildTxTest(String)
      Cause: ReflectionException: null
      Cause: java.lang.IllegalArgumentException: Unable to find operation runCreateObjectAndChildTxTest(String)
      faultActor:
      faultNode:
      faultDetail:
      {http://xml.apache.org/axis/}stackTrace: AxisFault
      faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
      faultSubcode:
      faultString: Problems while interfacing JMX.; nested exception is:
      MBeanException: ReflectionException: null
      Cause: java.lang.IllegalArgumentException: Unable to find operation runCreateObjectAndChildTxTest(String)
      Cause: ReflectionException: null
      Cause: java.lang.IllegalArgumentException: Unable to find operation runCreateObjectAndChildTxTest(String)
      faultActor:
      faultNode:
      faultDetail:

        • 1. Re: RemoteAdaptor - invoke(ObjectName, String, Object[], Str
          Chris Buckley Newbie

          Found the answer I was looking for in an article.

          // The connection URL.
          String endpoint = "http://roosevelt/jboss-net/services/RemoteAdaptor";


          Service service = new Service();
          Call call = (Call) service.createCall();
          call.setTargetEndpointAddress( new java.net.URL(endpoint) );
          //call.setOperationName("getDefaultDomain");
          //System.out.println("Default Domain: "+ call.invoke( new Object[]{}));

          QName qn = new QName("http://net.jboss.org/jmx", "ObjectNameType");
          call.registerTypeMapping(ObjectName.class, qn,
          new ObjectNameSerializerFactory(ObjectName.class, qn),
          new ObjectNameDeserializerFactory(ObjectName.class, qn));

          call.setOperationName("invoke");
          Object info = call.invoke(new Object[]{
          new ObjectName("jnms.test:service=HibernateTest"),
          new String("runCreateObjectAndChildTxTest"),
          new Object[]{"test-1"},
          new String[]{String.class.getName()}
          });
          //call.setOperationName("getMBeanCount");
          //Object info = call.invoke(new Object[]{});

          System.out.println("Info: "+info);
          }