英文:
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:
>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 -
...........
<more log data>
...........
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):
<script code above>
# Execute java binary
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>
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论