• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Strange Class Cast Error in CF

New Here ,
Dec 15, 2006 Dec 15, 2006

Copy link to clipboard

Copied

All,

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?

Thanks,
Ondis

TOPICS
Advanced techniques

Views

314

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 16, 2006 Dec 16, 2006

Copy link to clipboard

Copied

That used to be an HttpsUrlConnection bug in Coldfusion MX. I hadn't expected it to resurface in CFMX7. In any case, the link contains a workaround.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 16, 2006 Dec 16, 2006

Copy link to clipboard

Copied

Many thanks... Works great!
Ondis

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 16, 2006 Dec 16, 2006

Copy link to clipboard

Copied

LATEST
!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation