1 Reply Latest reply on Oct 20, 2010 8:32 PM by frh10 ff

    Error:javax.management.InstanceNotFoundException

    frh10 ff Newbie

      Hi,i want to  use Hornetq's API:JMSQueueControl to manage the message infomations.

      Here is my code:

      public class Test {
      private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://192.168.1.102:3000/jmxrmi";

      @SuppressWarnings("unchecked")
      public static void main(String[] args) {
        InitialContext ctx = null;
        QueueConnection connection = null;
        try {
         Properties props = new Properties();
         props.put(Context.INITIAL_CONTEXT_FACTORY,
           "org.jnp.interfaces.NamingContextFactory");
         props.put(Context.PROVIDER_URL,
           "192.168.1.102:1099");
         props.put(Context.URL_PKG_PREFIXES,
           "org.jboss.naming:org.jnp.interpaces");

         ctx = new InitialContext(props);
         QueueConnectionFactory factory = (QueueConnectionFactory) ctx
           .lookup("ConnectionFactory");
         connection = factory.createQueueConnection();
         Queue queue = (Queue) ctx.lookup("/queue/myqueue");
         ObjectName on = ObjectNameBuilder.DEFAULT
           .getJMSQueueObjectName(queue.getQueueName());
         JMXConnector connector = JMXConnectorFactory.connect(
           new JMXServiceURL(Test.JMX_URL), new HashMap());
         MBeanServerConnection mbsc = connector.getMBeanServerConnection();
         JMSQueueControl queueControl = (JMSQueueControl) MBeanServerInvocationHandler
           .newProxyInstance(mbsc, on, JMSQueueControl.class, false);
         System.out.println(queueControl.getConsumerCount());
        } catch (Exception e) {
         e.printStackTrace();
        }
      }
      }

      I already started with the properties on JVM follow the Hornetq's JMX examples.

      -Dcom.sun.management.jmxremote
      -Dcom.sun.management.jmxremote.port=3000
      -Dcom.sun.management.jmxremote.ssl=false
      -Dcom.sun.management.jmxremote.authenticate=false

      And i get the error:

      javax.management.InstanceNotFoundException: org.hornetq:module=JMS,type=Queue,name="myqueue"
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(Unknown Source)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(Unknown Source)
      at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(Unknown Source)
      at javax.management.remote.rmi.RMIConnectionImpl.doOperation(Unknown Source)
      at javax.management.remote.rmi.RMIConnectionImpl.access$200(Unknown Source)
      at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(Unknown Source)
      at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(Unknown Source)
      at javax.management.remote.rmi.RMIConnectionImpl.getAttribute(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
      at sun.rmi.transport.Transport$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Unknown Source)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
      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 com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
      at javax.management.remote.rmi.RMIConnectionImpl_Stub.getAttribute(Unknown Source)
      at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttribute(Unknown Source)
      at javax.management.MBeanServerInvocationHandler.invoke(Unknown Source)
      ... 2 more

       

      How can i solve this problem?Thanks!