[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-ssl]cu|| "java.lang.ClassCastException" with "javax.net.ssl" package



Hello everybody!
 
I have installed JDK1.4 and Tomcat 4.1.16 LE on a Windows 2000 machine.
 
To support SSL protocol in my servlet I use the version of JSSE API integrated in JDK 1.4:
 
import javax.net.ssl.*; //package present in JDK 1.4
...
URL url = new URL(urlString);
HttpsURLConnection Con = (HttpsURLConnection)url.openConnection();
....
 
in this way I receive this Exception when the servlet tries to connect to the https URL:
 
java.lang.ClassCastException: com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl
 
If I change the code in this way:
 
import com.sun.net.ssl.*; //package present in old JSSE 1.0.x API
 
...
URL url = new URL(urlString);
HttpsURLConnection Con = (HttpsURLConnection)url.openConnection();
....
 
all works correctly. This means that the servlet works if it uses "com.sun.net.ssl" package and not "javax.net.ssl".
How come? I would like to use javax.net.ssl package because it is more up-to-date and it is that one integrated
with JDK 1.4. Sincerely I don't know why Tomcat searchs for "com.sun.net.ssl package" and throws that Exception because I haven't installed in Tomcat old JSSE 1.0.x API!!!
 
I found indications about this problem at:
 
http://forum.java.sun.com/thread.jsp?thread=290800&forum=2&message=1146586
 
and at:
 
http://java.sun.com/j2se/1.4/docs/guide/security/jsse/JSSERefGuide.html#InstallProbs
 
but they aren't very clear to me....
 
Is it possible that Tomcat uses internally old JSSE 1.0.x API??
 
HOW CAN I USE "javax.net.ssl" without having the "java.lang.ClassCastException"???
 
I hope someone can help me!!
 
 
Thanks averybody in advance.
 
                                                        Luca