Failed to retrieve RMIServer stub ... non-JRMP server at remote endpoint when trying to connect to JBoss EAP 6 JMX
Environment
Red Hat JBoss Enterprise Application Platform (EAP) 6.x
Issue
- We are getting the error on remote monitoring access to JBoss EAP 6 via JMX :
Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: non-JRMP server at remote endpoint]
or:
| ERROR| App | Cannot connect to instance localhost:7199 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]
Resolution
Make sure the correct URL is being used to connect to the JMX server
The remote connection URL should be this below where jbossHost is the host/IP of that the JBoss server is listening on.
The default port is the jboss.management.native.port which defaults to 9999. Or if the JMX subsystem in JBoss EAP 6.x has been configured to use the remoting connector, it would be the remoting port which defaults to 4447.
service:jmx:remoting-jmx://jbossHost:9999
See also: How to connect to JBoss EAP 6 using JConsole
Root Cause
JMX is a standard protocol, however it can run over the top of multiple underlying protocol. The most common one is Java RMI, since that what the JDK's build in JMX functionality normally uses. There are a number of limitations to JMX-RMI, especially in the area of security, so EAP 6 instead runs JMX over the top of the JBoss Remoting protocol.
The "java.rmi.ConnectIOException: non-JRMP server at remote endpoint" error means that the client tried to use JMX-RMI but the server at the specified address did not. The corrosponding server-side "java.io.IOException: Received an invalid message length of 1246907721" error means it was expecting to have data for the Remoting-JMX protocol, but it instead received incorrect data. The basic problem is that the client is trying to use JMX-RMI to talk to a JMX-Remoting server.
The following are known causes:
- The JMX server listening in JBoss EAP 6.x is not an RMI Server
- The URL being used is wrong, it should be of the form:
service:jmx:remoting-jmx://jbossHost:9999, NOTservice:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.