We help IT Professionals succeed at work.
Get Started

ClassCastException while trying to create HttpsURLConnection

Last Modified: 2015-03-10
when I am trying to create httpsURLConnection like this:
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();

I am getting ClassCastException but its working fine in standalone application

Weblogic: 8

import java.net.URL;
import javax.net.ssl.HttpsURLConnection;

            URL url;
            try {

                  SSLContext ssl_ctx = SSLContext.getInstance("TLS");
                  TrustManager[] trust_mgr = get_trust_mgr();
                  ssl_ctx.init(null, trust_mgr,new SecureRandom()); // random number generator

                  url = new URL("https://.......");
                  HttpsURLConnection con = (HttpsURLConnection) url.openConnection();


Please Help me to resolve this problem
 Thanks you
Watch Question
This problem has been solved!
Unlock 3 Answers and 10 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE