Did you notice the unsurpassed apostrophe in the exception message?
java.net.ProtocolException: Unsupported protocol: https' ^
Update: this apostrophe seems to be just the quirk of how WebLogic HttpClient prints this exception.
A problem was discovered in the chat session with the root of asker access : it accesses the http: // URL, redirecting it to the https: // URL. The web server at this https address serves a certificate that its JRE / HttpClient does not trust.
The actual exception should be an SSLKeyException. I think WebLogic HttpClient is not correctly defining this issue as an unsupported protocol issue. I think the main problem:
<Warning> <Security> <BEA-090477> javax.net.ssl.SSLKeyException: [Security:090477] Certificate chain received from www.X.com - nnn.nnn.nnn.nnn was not trusted causing SSL handshake failure.
This is a message that Asker sees when directly accessing the https: // URL (and not through the redirect chain).
By default, Java Http [s] URLConnection should be redirected automatically and silently. If you're curious where you are redirected, try this code:
connection.setInstanceFollowRedirects(false); String location = connection.getHeaderField("Location"); System.out.println("Redirected to: " + location);
Note that the URL you are redirecting can also redirect you somewhere else over and over, up to http.maxRedirects times. Forwarding can "chain" this way. If they chain, you will need to continue redirecting until you reach a URL that will not redirect. This is why the URL connection eventually ends when setInstanceFollowRedirects(true) .
Also, I found the code in sun.net.www.protocol.http.HttpURLConnection, which apparently indicates that HttpURLConnection may not support switching protocols (HTTP β HTTPS) as part of its automatic forwarding of the following logic
private boolean followRedirect() throws IOException {
WebLogic has its own (different) implementation of HttpURLConnection, but may contain similar logic to prevent protocol switching. Thus, even if Asker solves its certificate trust issues, it still cannot use the HttpURLConnection to automatically follow the redirect chain going from HTTP to HTTPS. A setInstanceFollowRedirects(false) would be to use setInstanceFollowRedirects(false) and then redirect manually. Or directly access the HTTPS website.