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

EJP
You have some code for the separate JSSE that shipped prior to JDK 1.4. Delete the java.protocol.handler.pkgs setting, delete anything that adds the JSSE provider, delete anything that refers to com.sun.net.ssl.anything. If you have any other relices of the separate JSSE installation delete them too. The jre/lib/jsse.jar should be dated no earlier than December 2004.
1 - 1
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,850 views