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