Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ClassCastException: HttpsURLConnectionOldImpl in jdk 1.5.0_06

843790Apr 3 2007 — edited Apr 3 2007
Hello,

I getting a class cast exception in a java application when opening an https connection and cannot determine the reason for this.
I am not importing this old package. In fact in trying to resolve this problem, I have added a jvm param to insure the new package is being used.:
/usr/lib/jvm/java/bin/java  -Djava.protocol.handler.pkgs=sun.net.www.protocol.https.Handler   
Even after adding this start up parameter, I am still getting this cast exception. This exception does not occur all the time either. I haven't determined the pattern of when it works correctly i.e. loading the correct class, versus when it fails.

Any help would be appreciated in shedding some light on why this class is being loaded. The code snippet is below:

Java version 1.5.0_06

Red Hat Enterprise Linux WS release 3 (Taroon Update 8) Kernel release: 2.4.21-47.0.1.

Exception : java.lang.ClassCastException: com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl


Code snippet :
 

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

    	URL myURL = null;
    	try
    	{
    		myURL = new URL( BP_URL );
    	}
    	catch ( java.net.MalformedURLException ex )
    	{
    		if ( DEBUG )
    			System.err.println( ex.toString() );
    		throw new PreTransactionException( "URL is malformed: " + BP_URL );
    	}

    	.... ---- snip  paramters are added to the url ----

    	HttpsURLConnection hcon = null;
    	try
    	{        
    		//  ********** [ The class cast exception is Thrown here 
    		hcon =   ( HttpsURLConnection ) myURL.openConnection();
    	}
    	catch ( java.io.IOException ex )
    	{
    		if ( DEBUG )
    			System.err.println( ex.toString() );
    		throw new PreTransactionException(
    				"Unable to generate HTTPS connection: " + ex.toString() );
    	}
   ... sniip 
Thank you

Ursula Kellmann

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 1 2007
Added on Apr 3 2007
1 comment
5,840 views