2 Replies Latest reply on Oct 26, 2005 2:21 AM by joseph mao

    How to invoke mbean method from standalone class

    joseph mao Newbie

      I am writing a test code and need to control some mbeans in jboss.
      I am using jboss-4.0.3 with jdk 1.5.0_05-b05.
      Please read my code following:

      Properties prop = new Properties();
      prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      prop.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      prop.put(Context.PROVIDER_URL, "jnp://copper:1099");

      try {
      ic = new InitialContext(prop);
      } catch (NamingException e) {
      System.err.println("Could not locate initial context for server! " + e.getMessage());
      }

      RMIAdaptor server = null;
      Object obj = null;
      int ret = 0;
      System.out.println("here");
      try {
      server = (RMIAdaptor)ic.lookup("jmx/rmi/RMIAdaptor");
      } catch (NamingException e) {
      e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
      }

      System.out.println("here");
      ObjectName mgrName = null;
      try {
      mgrName = new ObjectName("amethon.mccf:service=PickUp");
      obj = server.invoke(mgrName, "startPickUp", new Object[] {}, new String[] {});
      } catch (Exception e) {
      System.err.println("Error invoking method");
      ret = -1;
      }

      It throws exception:
      javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.util.id.GUID; local class incompatible: stream classdesc serialVersionUID = 3289509836244263718, local class serialVersionUID = 6926421946503004889]]
      at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:970)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:613)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at com.amethon.mccf.functest.tools.JmxConsoleController.startPickup(JmxConsoleController.java:45)
      at com.amethon.mccf.functest.tools.JmxConsoleController.main(JmxConsoleController.java:95)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
      Caused by: javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.util.id.GUID; local class incompatible: stream classdesc serialVersionUID = 3289509836244263718, local class serialVersionUID = 6926421946503004889]
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:647)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:964)
      ... 10 more
      Caused by: java.io.InvalidClassException: org.jboss.util.id.GUID; local class incompatible: stream classdesc serialVersionUID = 3289509836244263718, local class serialVersionUID = 6926421946503004889
      at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:519)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
      at org.jboss.invocation.InvokerInterceptor.readExternal(InvokerInterceptor.java:125)
      at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
      at org.jboss.proxy.Interceptor.readExternal(Interceptor.java:66)
      at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
      at org.jboss.proxy.Interceptor.readExternal(Interceptor.java:66)
      at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
      at org.jboss.proxy.Interceptor.readExternal(Interceptor.java:66)
      at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
      at org.jboss.proxy.ClientContainer.readExternal(ClientContainer.java:111)
      at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
      at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
      at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:30)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:550)
      ... 13 more

      Any one can give me some suggestion will be really appreciated.
      Thanks.