强制转换异常:HttpsURLConnectionOldImpl v javax.net.ssl.HttpsURLConnection

强制转换异常:HttpsURLConnectionOldImpl v javax.net.ssl.HttpsURLConnection,java,https,coldfusion,Java,Https,Coldfusion,我遇到了一个复杂的运行时错误: java.lang.ClassCastException: com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl cannot be cast to javax.net.ssl.HttpsURLConnection 这是相关的代码 final SSLContext sslContext = SSLContext.getInstance(ALGORITHM_TLS_1_2); s

我遇到了一个复杂的运行时错误:

java.lang.ClassCastException: com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl cannot be cast to javax.net.ssl.HttpsURLConnection
这是相关的代码

final SSLContext sslContext = SSLContext.getInstance(ALGORITHM_TLS_1_2);
sslContext.init(null, new TrustManager[] {new TrustAllCertificates()}, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());

// Install the all-trusting host verifier
HttpsURLConnection.setDefaultHostnameVerifier(new TrustAllHosts());

// cookie connection
final URL authURL = new URL(data.getAuthURL());
final HttpsURLConnection httpsPost = (HttpsURLConnection) authURL.openConnection();
我尝试退出HttpURLConnection,但我的目标系统不喜欢它

这段代码在本地运行良好,但当我尝试将其作为ColdFusion 2018服务器的附加组件实现时,会引发运行时异常

URL是java.net.URL,data.getAuthURL是一个字符串,它返回一个字符串,以便于挑剔

我假设authURL.openConnection是com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl


我如何说服it部门使用正确的实现?或者解决问题,否则如果我在这个特定的例子中没有问正确的问题,我会改变

这个 最终URL authURL=new URLdata.getAuthURL

对此 最终URL authURL=new URLnull,data.getAuthURL,new sun.net.www.protocol.https.Handler

这还需要在构建时更新JRE中的访问策略

问题在于环境。当作为用户库加载到ColdFusion服务器上时,您不会得到预期的协议实现,而是得到ColdFusion服务器正在使用的协议实现


原始问题中的代码在大多数环境中都是正确的。这里需要这个乱码,因为不允许我选择实现。

我没有任何com.sun.net导入。我确实尝试过创建这样的URL,这样就消除了错误,但未能从服务器连接最终URL authURL=new URLnull,data.getAuthURL,new sun.net.www.protocol.https.Handler;我尝试的一切似乎都在IDE上运行良好,但没有任何东西想在ColdFusin下作为用户库正常运行检查其他内容。。。我可能已经解决了这个问题,并遇到了网络故障-现在正在检查。。。