Resolving 'java.net.MalformedURLException: unknown protocol: http-remoting' in Red Hat JBoss EAP 7.4.21
Environment
- Red Hat JBoss Enterprise Application Platform 7.4.21
Issue
- Client encounters the following error when attempting to connect weblaunch-based client to JBoss server:
java.net.MalformedURLException: unknown protocol: remote+http
at java.base/java.net.URL.<init>(URL.java:681)
at java.base/java.net.URL.<init>(URL.java:569)
at java.base/java.net.URL.<init>(URL.java:516)
- Error stack includes "java.lang.NullPointerException: Cannot invoke "String.length()" because "this.input" is null" and traces back to URI parsing issues in Java's URI class.
- The error originates from URI.java:3167, indicating a problem with the URI format or configuration in the client's connection setup.
- Additional context suggests a potential resolution involves adding JBoss EJB client JARs to the client's classpath.
Resolution
- Make sure to use EAP_HOME\bin\client\jboss-client.jar in the application.
- To address this, the namingUrl must be normalized before being used to construct a URL object. As you’ve already identified, the correct approach is to replace the non-standard protocol with a supported one:
namingUrl = namingUrl
.replace("remote+http://", "http://")
.replace("remote+https://", "https://");
Root Cause
- This behavior is expected. The java.net.URL class does not recognize the remote+http (or remote-http) protocol, which leads to the MalformedURLException.
- The remote+http protocol is specific to EJB client communication and is typically used when invoking remote EJBs, for example:
jndiProps.put(Context.PROVIDER_URL, "remote+http://localhost:8080");
- occurs at the following line in your code:
URL url = new URL(new URL(namingUrl), path.toString());
SBR
Components
Category
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.