3 Replies Latest reply on Dec 16, 2006 10:18 PM by BKBK

    Strange Class Cast Error in CF


      My Goal: Extending CF with CFX tag that communicates with another server using bi-directional SSL

      Outside of CF my code works fine (as a servlet for example). However within CF MX7 Java VM 1.4.2_05-b04 I get a class cast exception on line 4 of the following:

      url = new URL(m_sUrl); // where m_sUrl is the url of the server I want to communicate with

      conn = (java.net.HttpURLConnection) url.openConnection();

      SSLSocketFactory sf = ssl.getSocketFactory();

      ( (javax.net.ssl.HttpsURLConnection) conn).setSSLSocketFactory(sf); // The offending line when run in CFMX7

      When this code is run in the context of a servlet (Tomcat for example) it runs fine. However, when running it the context of a CFX tag I get the java.lang.ClassCastException when casting to the httpsURLConnection.

      The java.net and javax.net.ssl classes in use are:
      public abstract class URLConnection {...}
      abstract public class HttpURLConnection extends URLConnection {...}
      public abstract class HttpsURLConnection extends HttpURLConnection{...}

      So, I am a bit confused as to why CF is throwing the ClassCastException...

      Does anyone know what's going on here?