I have a Java client that successfully connects to ActiveMQ Artemis JMX when both are running on the same machine. The client uses the following code:
public static void main(String[] args) throws IOException, MalformedObjectNameException, ReflectionException, AttributeNotFoundException, InstanceNotFoundException, MBeanException
{
private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi";
System.out.println("Hello, Artemis!");
HashMap env = new HashMap();
String[] creds = {"artemis", "artemis"};
env.put(JMXConnector.CREDENTIALS, creds);
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), env);
MBeanServerConnection mBeanServer = connector.getMBeanServerConnection();
System.out.println("Connected to the server");
}
ISSUE: When I move ActiveMQ Artemis into a Docker container with necessary ports exposed, I get the following error:
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment;
What we tried:
- Exposed JMX Ports in Docker
- Added Java Argument in
artemis.profile
(-Djava.rmi.server.hostname=localhost
) - Enabled Connector Element in management.xml (
<connector connector-port="1099" connector-host="localhost"/>
). Also tried replacinglocalhost
with0.0.0.0
, but the issue persists. - After building and running the Docker image locally, I confirmed that RMI registry is listening on port
1099
, but I still cannot connect.
I have a Java client that successfully connects to ActiveMQ Artemis JMX when both are running on the same machine. The client uses the following code:
public static void main(String[] args) throws IOException, MalformedObjectNameException, ReflectionException, AttributeNotFoundException, InstanceNotFoundException, MBeanException
{
private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi";
System.out.println("Hello, Artemis!");
HashMap env = new HashMap();
String[] creds = {"artemis", "artemis"};
env.put(JMXConnector.CREDENTIALS, creds);
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), env);
MBeanServerConnection mBeanServer = connector.getMBeanServerConnection();
System.out.println("Connected to the server");
}
ISSUE: When I move ActiveMQ Artemis into a Docker container with necessary ports exposed, I get the following error:
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment;
What we tried:
- Exposed JMX Ports in Docker
- Added Java Argument in
artemis.profile
(-Djava.rmi.server.hostname=localhost
) - Enabled Connector Element in management.xml (
<connector connector-port="1099" connector-host="localhost"/>
). Also tried replacinglocalhost
with0.0.0.0
, but the issue persists. - After building and running the Docker image locally, I confirmed that RMI registry is listening on port
1099
, but I still cannot connect.
- Any feedback here? – Justin Bertram Commented Feb 10 at 3:12
1 Answer
Reset to default 2I recommend you try setting the rmi-registry-port
attribute on the connector
, e.g.:
<connector connector-port="1099" rmi-registry-port="1100" connector-host="localhost"/>
Then ensure that port is exposed by Docker.