MalformedURLException Unsupported protocol remoting-jmx when JMX client tries to connect to JBoss EAP 6 MBean Server
Issue
- Getting Unsupported protocol when trying to connect to JMX using
remoting-jmxprotocol from a client application running in JBoss EAP 6.0.x. The exception is:
03:09:24,429 ERROR java.net.MalformedURLException: Unsupported protocol: remoting-jmx
03:09:24,430 ERROR at javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnectorFactory.java:327)
03:09:24,430 ERROR at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:247)
03:09:24,430 ERROR at com.jboss.examples.ejb.HelloBean.printMBeanCount(PrintMBeansSingleton.java:57)
...
- The client code connection is:
import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
@Stateless
public class HelloBean {
public int printMBeanCount() throws Exception {
String host = "localhost";
int port = 9999; // management-native port
String urlString = System.getProperty("jmx.service.url","service:jmx:remoting-jmx://" + host + ":" + port);
JMXConnector jmxConnector = null;
try {
JMXServiceURL serviceURL = new JMXServiceURL(urlString);
JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null);
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
return connection.getMBeanCount();
} finally {
if(jmxConnector != null) jmxConnector.close();
}
}
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
