title: ActiveMQ command lines exception: "Failed to retrieve RMIServer stub"
body: <p>I have <strong>ActiveMQ 5.10.0</strong> running on a server, and I'm trying to use the command lines to extract information that I'd see in the AMQ Web Console (<a href="https://activemq.apache.org/web-console" rel="nofollow noreferrer">https://activemq.apache.org/web-console</a>).</p>
  
  <p>None of the command lines work.  ie. in the bin folder is the <code>activemq</code> script to do command lines, (such as <code>./activemq bstat</code> or <code>./activemq list</code>) but I keep getting this error:</p>
  
  <pre><code>Connecting to JMX URL: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
  ERROR: java.lang.RuntimeException: Failed to execute list task. Reason: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
          java.net.ConnectException: Connection refused]
  java.lang.RuntimeException: Failed to execute list task. Reason: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
  </code></pre>
  
  <p>Oddly enough, when I download and start the same version of AMQ on my local pc, the AMQ command lines work.  This is the output I get when attempting the <code>list</code> command:</p>
  
  <pre><code>&gt;activemq list
  Java Runtime: Oracle Corporation 1.8.0_161 C:\Program Files\Java\jdk1.8.0_161\jre
    Heap sizes: current=1005056k  free=989327k  max=1005056k
      JVM args: -Dcom.sun.management.jmxremote -Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -
  ...........
  &lt;more log data&gt;
  ...........
  useJmxServiceUrl Found JMS Url: service:jmx:rmi://127.0.0.1/stub/rO0ABXNyAC5qYXZheC5tYW5hZ2VtZW50LnJlbW90ZS5ybWkuUk1JU2VydmVySW1wbF9TdHViAAAAAAAAAAICAAB4cgAaamF2YS5ybWkuc2VydmVyLlJlbW90ZVN0dWLp/tzJi+FlGgIAAHhyABxqYXZhLnJtaS5zZXJ2ZXIuUmVtb3RlT2JqZWN002G0kQxhMx4DAAB4cHc5AAtVbmljYXN0UmVmMgAADjE2OS4yNTQuNjguMjM3AADDoqnwRJwaEyt6UvhZyAAAAXFkS9pNgAEAeA==
  Connecting to pid: 3332
  brokerName = localhost
  </code></pre>
  
  <p>How do I get the same commands to work that is running on the remote server?</p>