6 Replies Latest reply on Jun 7, 2005 9:35 AM by adrian.bigland

    How to lookup RMI Adapter

    saroj sivakumar Newbie

      when i try to lookup the RMIAdapter(using the jndi name:jmx/rmi/RMIAdapter ),i get the exception like
      "NameNotFoundException: jmx not bound" .

      i used the following code to lookup the RMIAdapter


      String adapterName = "jmx/rmi/RMIAdaptor";
      ctx = new InitialContext();
      Object obj = ctx.lookup(adapterName);
      RMIAdaptor adaptor = (RMIAdaptor) obj;


      Can anyone help me out.

      Regards,
      Sivaku

        • 1. Re: How to lookup RMI Adapter
          Elias Ross Master

          Perhaps your jndi.properties is not set?

          • 2. Re: How to lookup RMI Adapter
            Anil Saldanha Master

            Looks like there may be an additional jndi.properties somewhere that is being used instead of the one you provided.

            Have you specified a jndi.properties file?

            • 3. Re: How to lookup RMI Adapter
              Anil Saldanha Master

              Ignore my last post. I was answering a similar post without refreshing the browser.

              • 4. Re: How to lookup RMI Adapter
                Anil Saldanha Master

                http://wiki.jboss.org/wiki/Wiki.jsp?page=JNDIClientConfiguration

                Also, use MBeanServerConnection instead of RMIAdaptor.

                import javax.management.MBeanServerConnection;
                ....
                 protected MBeanServerConnection rmiserver = null;
                 private void getMBeanServer(InitialContext ctx)
                 {
                 if (ctx == null)
                 throw new IllegalArgumentException("Initial Context passed is null");
                 try
                 {
                 rmiserver = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor");
                 } catch (NamingException e)
                 {
                 log.debug(e);
                 }
                 if (rmiserver == null)
                 throw new IllegalStateException( "MBeanServerConnection is null");
                
                 }
                


                MBeanServerConnection represents the MBeanServer and you can invoke operations as follows:
                 /**
                 * Invoke an Operation on the MBean
                 *
                 * @param oname ObjectName of the MBean
                 * @param methodname Name of the operation on the MBean
                 * @param pParams Arguments to the operation
                 * @param pSignature Signature for the operation.
                 * @return result from the MBean operation
                 * @throws Exception
                 */
                 public Object invokeOperation(ObjectName oname,
                 String methodname, Object[] pParams,
                 String[] pSignature)
                 throws Exception
                 {
                 Object result = null;
                 if( rmiserver == null)
                 throw new IllegalStateException( "MBeanServerConnection is null");
                 try
                 {
                 result = rmiserver.invoke(oname, methodname, pParams, pSignature);
                 } catch (Exception e)
                 {
                 log.debug(e);
                 }
                
                 return result;
                 }
                


                • 5. Re: How to lookup RMI Adapter
                  saroj sivakumar Newbie

                  jndi.properties is set,still i am getting the same error.

                  • 6. Re: How to lookup RMI Adapter
                    adrian.bigland Newbie

                    It may be obvious but if you can, write a little code that iterates over the
                    naming enumeration of your initial context, and print out what content it has, if any. This might give you a better idea of which naming service you are actaully connected to.

                    You could compare this with the JNDIView list you get from the JMX console - if the two differ then you are not connecting to the JNDI tree you thought you were connecting to.

                    This doesn't solve your problem, of course, but it might make things a bit clearer. If you can iterate to the adapter but can't look it up directly this would probably mean a spelling mistake in the JNDI name, for example.