2015-04-06 43 views
3

我的應用程序拋出這個錯誤:GAE網址提取服務爲HTTPS

[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網址提取服務支持HTTPS後會出現什麼問題。

+0

聞起來像一個導入問題,你可以請提供該類的導入塊? – jirungaray 2015-04-06 22:18:26

回答

3

嘗試

HttpURLConnection connection = (HttpURLConnection) verifierURL.openConnection(); 

,而不是

HttpsURLConnection connection = (HttpsURLConnection) verifierURL.openConnection(); 

它將創建它所需要的下方,也爲HTTPS,但不要強迫劇組到HTTPS,因爲它使用了類(URLFetchServiceStreamHandler $連接)taht擴展HttpURLConnection但不HttpsURLConnection