1 Reply Latest reply on Mar 18, 2009 6:49 PM by sileshikassa

    Looking up RMIAdaptor sometimes results in java.rmi.NoSuchOb

    sileshikassa

      I am using JBoss remote JMX object invocation via RMIAdaptor: jmx/invoker/RMIAdaptor which is obtained via JNDI. I run into a problem time to time with NoSuchObjectException when I look up for RMIAdaptor and could not recover from it. I have a couple of JBoss servers: one is primary and the other is host standby. The problem occurs after the switch over to standby. Any help is appreciated .

      ....
      Caused by: java.rmi.NoSuchObjectException: no such object in table
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
      at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
      at sun.rmi.server.UnicastRef.invoke(Unknown Source)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
      ... 92 more

        • 1. Re: Looking up RMIAdaptor sometimes results in java.rmi.NoSu
          sileshikassa

          Here is the relevant code used:

          import java.util.Hashtable;
          import java.util.Properties;

          import javax.management.MBeanServerConnection;
          import javax.management.MBeanServerInvocationHandler;
          import javax.management.ObjectName;
          import javax.naming.Context;
          import javax.naming.InitialContext;
          import javax.naming.NamingException;

          import org.jboss.logging.Logger;

          public class MBeanLocator
          {
          private static final Logger log = Logger.getLogger(PeerLocator.class);

          public static FooMBean locateMBean(String ipAddress)
          {
          Hashtable<String, String> props = new Hashtable<String, String>();
          MBeanServerConnection wrapper = null;
          Properties props = new Properties();
          InitialContext ctx = null;

          try
          {
          props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
          props.put(Context.PROVIDER_URL, "jnp://" + ipAddress + ":" + 1099 + "/");
          props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
          props.put(Context.SECURITY_PRINCIPAL, "tpAdmin");
          props.put(Context.SECURITY_CREDENTIALS, "rp!3$0mS");

          props.put("jnp.timeout", "10000");
          props.put("jnp.sotimeout", "3000");
          props.put("jnp.maxRetries", "5");


          ctx = new InitialContext(props);

          MBeanServerConnection server = (MBeanServerConnection) ctx.lookup(jmx/invoker/RMIAdaptor);
          Object proxy = Proxy.newProxyInstance(MBeanServerProxy.class.getClassLoader(),
          MBeanServerProxy.INTERFACES,
          new MBeanServerProxy(server));
          wrapper = (MBeanServerConnection) proxy;
          ObjectName objectName = new ObjectName("jboss:service=FooMBean");
          fooMbean = (FooMBean) MBeanServerInvocationHandler.newProxyInstance(wrapper,
          objectName,
          RemotePeerInterfaceMBean.class,
          true);
          }
          catch (Throwable e)
          {
          String msg = "Unable to lookup remote MBeanServer. cause: " + e;
          log.error(msg, e);
          }
          finally
          {
          try {
          if (ctx != null) {
          ctx.close();
          }
          } catch (Throwable e1) {
          }
          }

          return fooMbean;
          }
          }