How do I fix a 'Failed to retrieve RMIServer stub' JMX error?
You can specify same port for both JMX and RMI conversation:
-Dcom.sun.management.jmxremote.port=8084
-Dcom.sun.management.jmxremote.rmi.port=8084
The problem is that even if JMX is configured to listen on port 8084, after the initial connection is made, the JMX host will dynamically pick a different port for the rest of the "conversation". My firewall allowed traffic through 8084, but was blocking the subsequent traffic.
There are two options.
- Allow inbound traffic on all ephemeral ports (yikes!).
- Develop a JMX wrapper that uses a single port for communication.
I struggled with this same issue trying to connect to our new Tomcat8 VMs over JMX (using VisualVM). Our Linux team had to open a ticket with Redhat to help us troubleshoot. But I stumbled on this article before they could resolve our issue.
The solution as mentioned above was to add
-Dcom.sun.management.jmxremote.rmi.port=X
and X
should match whatever your setting is for
-Dcom.sun.management.jmxremote.port
Complete List of Args:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8091
-Dcom.sun.management.jmxremote.rmi.port=8091
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=MYHOST
Hope this helps someone else having the same issue. Good luck!
Searching for a solution to an identical problem (after solving many many others, ready to pull my hair), I found this thread, and I can share that the solution that worked for me was https://serverfault.com/a/872756/579378 by @MaxRelax -- I would have upvoted his answer but I don't have enough reputation.
Oh, one more thing: Since -Dcom.sun.management.jmxremote.ssl=false
be sure to check the 'Do not require SSL connection' checkbox in the Java Visual VM dialog for adding a JMX connection.