我的应用正在抛出此错误:
[INFO] Caused by: java.lang.ClassCastException: com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection cannot be cast to javax.net.ssl.HttpsURLConnection
[INFO] at info.modprobe.browserid.Verifier.verify(Verifier.java:76)
导致错误的代码是:
URL verifierURL = new URL(this.url);
String response = "";
HttpsURLConnection connection = (HttpsURLConnection) verifierURL
.openConnection(); // error here...
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
"application/json; charset=utf-8");
connection.setDoOutput(true);
尝试使用此library进行Mozilla个人身份验证时。我想知道可能是什么问题,因为GAE URL Fetch Service支持HTTPS。
答案 0 :(得分:4)
尝试
HttpURLConnection connection = (HttpURLConnection) verifierURL.openConnection();
而不是
HttpsURLConnection connection = (HttpsURLConnection) verifierURL.openConnection();
它将创建它所需的内容,也适用于HTTPS,但不要强制转换为HttpS,因为它使用类(URLFetchServiceStreamHandler $ Connection)taht扩展HttpURLConnection而不是HttpsURLConnection