Solving Unsupported protocol: remote+http

This article shows how to fix the error β€œUnsupported protocol: remote+http” which can happen if you try to connect via JMX to a java process, such as JBoss/WildFly application server.

In some cases, the JMX subsystem registers a service with the Remoting endpoint so that you can obtain remote access to JMX over the exposed Remoting connector. This is the case of a JMX Connection String such as the following one:

service:jmx:remote+http://localhost:9990

Here is an example code snipped which connects to WildFly via JMX through the port 9990:

String host = "localhost";
int port = 9990;  // management-http port
String urlString = "service:jmx:remote+http://" + host + ":" + port;
System.out.println("\n\n\t****  urlString: "+urlString);;
JMXServiceURL serviceURL = new JMXServiceURL(urlString);

Map map = new HashMap();
String[] credentials = new String[] { "admin", "admin" };
map.put("jmx.remote.credentials", credentials);
JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, map);

If you run the above example, without any extra dependency, you will hit the following error:

Exception in thread "main" java.net.MalformedURLException: Unsupported protocol: remote+http
at java.management/javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnectorFactory.java:366) 

This is because, to run JMX over RMI you need to include the wildfly-client-all dependency for your server version. For example:

    <dependency>
      <groupId>org.wildfly</groupId>
      <artifactId>wildfly-client-all</artifactId>
      <version>26.0.0.Final</version>
    </dependency>

To learn more about WildFly and JMX, check this article: Managing MBeans with WildFly

Found the article helpful? if so please follow us on Socials