ActiveMQ命令行异常:“无法检索RMIServer存根”

huangapple go评论101阅读模式
英文:

ActiveMQ command lines exception: "Failed to retrieve RMIServer stub"

问题

我在服务器上运行着 ActiveMQ 5.10.0,并尝试使用命令行提取我在AMQ Web控制台(https://activemq.apache.org/web-console)中看到的信息。

所有的命令行都无法工作。即在bin文件夹中有一个名为activemq的脚本用于执行命令行,(例如./activemq bstat./activemq list),但我一直在收到以下错误消息:

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:

奇怪的是,当我在本地计算机上下载并启动相同版本的AMQ时,AMQ命令行可以正常工作。以下是我尝试执行list命令时的输出:

> 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 -
...........
<更多日志数据>
...........
useJmxServiceUrl Found JMS Url: service:jmx:rmi://127.0.0.1/stub/rO0ABXNyAC5qYXZheC5tYW5hZ2VtZW50LnJlbW90ZS5ybWkuUk1JU2VydmVySW1wbF9TdHViAAAAAAAAAAICAAB4cgAaamF2YS5ybWkuc2VydmVyLlJlbW90ZVN0dWLp/tzJi+FlGgIAAHhyABxqYXZhLnJtaS5zZXJ2ZXIuUmVtb3RlT2JqZWN002G0kQxhMx4DAAB4cHc5AAtVbmljYXN0UmVmMgAADjE2OS4yNTQuNjguMjM3AADDoqnwRJwaEyt6UvhZyAAAAXFkS9pNgAEAeA==
Connecting to pid: 3332
brokerName = localhost

如何使在远程服务器上运行的相同命令正常工作?

英文:

I have ActiveMQ 5.10.0 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 (https://activemq.apache.org/web-console).

None of the command lines work. ie. in the bin folder is the activemq script to do command lines, (such as ./activemq bstat or ./activemq list) but I keep getting this error:

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:

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 list command:

&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

How do I get the same commands to work that is running on the remote server?

答案1

得分: 1

看起来,根据StackOverflow和其他网站上类似的问题,似乎我需要在启动ActiveMQ时添加JVM参数。

AMQ的bin文件夹包含一个脚本activemq,在相同的bin文件夹中,该脚本启动了一个activemq.jar文件。

我需要更新脚本文件的一部分,以包括这些JVM参数(在您的脚本中,不要在行末包含#注释):

<script code above>
       # 执行java二进制文件
       if [ -n "$PIDFILE" ] && [ "$PIDFILE" != "stop" ];then
    
          $EXEC_OPTION $DOIT_PREFIX "$JAVACMD $ACTIVEMQ_OPTS $ACTIVEMQ_DEBUG_OPTS \
                  -Dactivemq.classpath=\"${ACTIVEMQ_CLASSPATH}\" \
                  -Dactivemq.home=\"${ACTIVEMQ_HOME}\" \
                  -Dactivemq.base=\"${ACTIVEMQ_BASE}\" \
                  -Dactivemq.conf=\"${ACTIVEMQ_CONF}\" \
                  -Dactivemq.data=\"${ACTIVEMQ_DATA}\" \
                  -Dcom.sun.management.jmxremote \                    #THIS is added
                  -Dcom.sun.management.jmxremote.port=1099 \          #THIS is added
                  -Dcom.sun.management.jmxremote.rmi.port=1099 \      #THIS is added 
                  -Dcom.sun.management.jmxremote.authenticate=false \ #THIS is added
                  -Dcom.sun.management.jmxremote.ssl=false \          #THIS is added
                  $ACTIVEMQ_CYGWIN \
                  -jar \"${ACTIVEMQ_HOME}/bin/activemq.jar\" $COMMANDLINE_ARGS >/dev/null 2>&1 &
                  RET=\"$?\"; APID=\"$!\";
                  echo $APID > $PIDFILE;
                  echo "INFO: pidfile created : '$PIDFILE' (pid '$APID')";exit $RET" $DOIT_POSTFIX
          RET="$?"
<script code below>

之后,我只需运行./activemq脚本,现在我能够像在我的机器上运行的AMQ一样执行命令行操作。

英文:

So looking at similar issues on StackOverflow and other sites, it seems like I need to add JVM arguments to ActiveMQ when its kicked off.

The bin folder of AMQ contains a script activemq, in the same bin folder that script kicks off an activemq.jar file.

I needed to update part of the script file to include those JVM arguments (in your script don't include the # comments at the end of the line):

&lt;script code above&gt;
       # Execute java binary
       if [ -n &quot;$PIDFILE&quot; ] &amp;&amp; [ &quot;$PIDFILE&quot; != &quot;stop&quot; ];then
    
          $EXEC_OPTION $DOIT_PREFIX &quot;$JAVACMD $ACTIVEMQ_OPTS $ACTIVEMQ_DEBUG_OPTS \
                  -Dactivemq.classpath=\&quot;${ACTIVEMQ_CLASSPATH}\&quot; \
                  -Dactivemq.home=\&quot;${ACTIVEMQ_HOME}\&quot; \
                  -Dactivemq.base=\&quot;${ACTIVEMQ_BASE}\&quot; \
                  -Dactivemq.conf=\&quot;${ACTIVEMQ_CONF}\&quot; \
                  -Dactivemq.data=\&quot;${ACTIVEMQ_DATA}\&quot; \
                  -Dcom.sun.management.jmxremote \                    #THIS is added
                  -Dcom.sun.management.jmxremote.port=1099 \          #THIS is added
                  -Dcom.sun.management.jmxremote.rmi.port=1099 \      #THIS is added 
                  -Dcom.sun.management.jmxremote.authenticate=false \ #THIS is added
                  -Dcom.sun.management.jmxremote.ssl=false \          #THIS is added
                  $ACTIVEMQ_CYGWIN \
                  -jar \&quot;${ACTIVEMQ_HOME}/bin/activemq.jar\&quot; $COMMANDLINE_ARGS &gt;/dev/null 2&gt;&amp;1 &amp;
                  RET=\&quot;$?\&quot;; APID=\&quot;$!\&quot;;
                  echo $APID &gt; $PIDFILE;
                  echo \&quot;INFO: pidfile created : &#39;$PIDFILE&#39; (pid &#39;$APID&#39;)\&quot;;exit $RET&quot; $DOIT_POSTFIX
          RET=&quot;$?&quot;
&lt;script code below&gt;

Afterwards I just start the ./activemq script, and now I'm able to do the Command Lines as I could do on AMQ running on my machine.

huangapple
  • 本文由 发表于 2020年4月11日 01:15:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/61145272.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定