user1730838 user1730838 - 16 days ago 6
Apache Configuration Question

Can not stop a JMS broker using activemq-admin.bat when the JAVA_HOME points to JRE 1.8

I can not stop a JMS broker using an activemq-admin.bat script when the JAVA_HOME points to a JRE (1.8.111). The problem does not appear when a JDK is used.
In the script an ACTIVEMQ_SUNJMX_START parameter was uncommented and a default port was changed to 61099 like this:

"set ACTIVEMQ_SUNJMX_START=-Dcom.sun.management.jmxremote.port=61099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"


Somehow the port looks to be ignored...

Do we need a JDK to stop the broker?
Any Idea?

JRE 1.8.111

PATH\bin>call "..\middleware\apache-activemq-5.14.0\bin\activemq-admin.bat" "stop"
Java Runtime: Oracle Corporation 1.8.0_111 C:\Program Files\Java\jre1.8.0_111
Heap sizes: current=251392k free=248770k max=3706880k
JVM args: -Dactivemq.classpath=PATH\middleware\apache-activemq-5.14.0\bin..\conf;_PROGRAM_DATA_\middleware\apache-activemq-5.14.0; -Dactivemq.home=PATH\middleware\apache-activemq-5.14.0\bin.. -Dactivemq.base=PATH\middleware\apache-activemq-5.14.0\bin.. -Dactivemq.data=_PROGRAM_DATA_\middleware\apache-activemq-5.14.0 -Djava.io.tmpdir=_PROGRAM_DATA_\middleware\apache-activemq-5.14.0\tmp -Dactivemq.conf=PATH\middleware\apache-activemq-5.14.0\bin..\conf
Extensions classpath:
[PATH\middleware\apache-activemq-5.14.0\bin..\lib,PATH\middleware\apache-activemq-5.14.0\bin..\lib\camel,PATH\middleware\apache-activemq-5.14.0\bin..\lib\optional,PATH\middleware\apache-activemq-5.14.0\bin..\lib\web,PATH\middleware\apache-activemq-5.14.0\bin..\lib\extra]
ACTIVEMQ_HOME: PATH\middleware\apache-activemq-5.14.0\bin..
ACTIVEMQ_BASE: PATH\middleware\apache-activemq-5.14.0\bin..
ACTIVEMQ_CONF: PATH\middleware\apache-activemq-5.14.0\bin..\conf
ACTIVEMQ_DATA: _PROGRAM_DATA_\middleware\apache-activemq-5.14.0
Connecting to JMX URL: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
INFO: Broker not available at: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi


JDK 1.8.111

PATH\bin>call "..\middleware\apache-activemq-5.14.0\bin\activemq-admin.bat" "stop"
Java Runtime: Oracle Corporation 1.8.0_111 C:\Program Files\Java\jdk1.8.0_111\jre
Heap sizes: current=251392k free=248770k max=3706880k
JVM args: -Dactivemq.classpath=PATH\middleware\apache-activemq-5.14.0\bin..\conf;_PROGRAM_DATA_\middleware\apache-activemq-5.14.0; -Dactivemq.home=PATH\middleware\apache-activemq-5.14.0\bin.. -Dactivemq.base=PATH\middleware\apache-activemq-5.14.0\bin.. -Dactivemq.data=_PROGRAM_DATA_\middleware\apache-activemq-5.14.0 -Djava.io.tmpdir=_PROGRAM_DATA_\middleware\apache-activemq-5.14.0\tmp -Dactivemq.conf=PATH\middleware\apache-activemq-5.14.0\bin..\conf
Extensions classpath:
[PATH\middleware\apache-activemq-5.14.0\bin..\lib,PATH\middleware\apache-activemq-5.14.0\bin..\lib\camel,PATH\middleware\apache-activemq-5.14.0\bin..\lib\optional,PATH\middleware\apache-activemq-5.14.0\bin..\lib\web,PATH\middleware\apache-activemq-5.14.0\bin..\lib\extra]
ACTIVEMQ_HOME: PATH\middleware\apache-activemq-5.14.0\bin..
ACTIVEMQ_BASE: PATH\middleware\apache-activemq-5.14.0\bin..
ACTIVEMQ_CONF: PATH\middleware\apache-activemq-5.14.0\bin..\conf
ACTIVEMQ_DATA: _PROGRAM_DATA_\middleware\apache-activemq-5.14.0
useJmxServiceUrl Found JMS Url: service:jmx:rmi://127.0.0.1/stub/rO0ABXNyAC5qYXZheC5tYW5hZ2VtZW50LnJlbW90ZS5ybWkuUk1JU2VydmVySW1wbF9TdHViAAAAAAAAAAICAAB4cgAaamF2YS5ybWkuc2VydmVyLlJlbW90ZVN0dWLp/tzJi+FlGgIAAHhyABxqYXZhLnJtaS5zZXJ2Z
XIuUmVtb3RlT2JqZWN002G0kQxhMx4DAAB4cHc5AAtVbmljYXN0UmVmMgAADjE5Mi4xNjguMTAwLjIwAAD9nHXsmR+4orQ3llsk9wAAAVhxZdSygAIAeA==
Connecting to pid: 5020
Stopping broker: MYBROKER

Answer

It's because ActiveMQ uses the Java Attach API to automatically discover the JMX URL. To use this API the classes are loaded from $JAVA_HOME\..\lib\tools.jar. As tools.jar is part of the JDK (see JDK files) this will fail for a JRE (not the one which comes with the JDK $JDK_HOME\jre).

To stop the broker with a JRE you must provide the JMX URL.

set ACTIVEMQ_OPTS=-Dactivemq.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:61099/jmxrmi
activemq-admin.bat stop

The connection message would look like

Connecting to JMX URL: service:jmx:rmi:///jndi/rmi://localhost:61099/jmxrmi