Getting java.lang.ClassCastException: HttpsURLConnectionOldImpl from an application running inside JBoss EAP
Issue
- The application running on EAP needs to establish an HTTPS connection to another application.
- While trying to establish the HTTPS connection we are getting a ClassCastException in one of our application server while in the other server, the HTTPS connection works perfectly fine.
- Same code is deployed in both application servers.
- Provided below is an extract of the code:
HttpsURLConnection con = null;
URL url = new URL("https://host:port/resource");
try {
SSLContext ssl_ctx = SSLContext.getInstance("TLS");
TrustManager[] trust_mgr = get_trust_mgr();
ssl_ctx.init(null, trust_mgr, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(ssl_ctx.getSocketFactory());
con = (HttpsURLConnection) url.openConnection();//Exception thrown here
Exception detail:
java.lang.ClassCastException: com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl cannot be cast to javax.net.ssl.HttpsURLConnection
Environment
- Red Hat JBoss Enterprise Application Platform 5.1.2
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.
