URLFetchServiceStreamHandler$Connection cannot be cast to HttpsURLConnection

127 views
Skip to first unread message

Shachar Grembek

unread,
Feb 14, 2017, 4:03:28 PM2/14/17
to Google App Engine

Hi,


I am using the Zendesk java client (https://github.com/cloudbees/zendesk-java-client) on my Google App Engine server and I have a runtime issue that prevents me from using the SDK. Can you please advise:

When I call the Zendesk SDK, I get on the server:


I am using JDK 7 with App Engine SDK 1.9.49


Uncaught exception from servlet java.lang.ClassCastException: com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection cannot be cast to javax.net.ssl.HttpsURLConnection
at com
.ning.http.client.providers.jdk.JDKAsyncHttpProvider.createUrlConnection(JDKAsyncHttpProvider.java:184)
at com
.ning.http.client.providers.jdk.JDKAsyncHttpProvider.execute(JDKAsyncHttpProvider.java:147)
at com
.ning.http.client.providers.jdk.JDKAsyncHttpProvider.execute(JDKAsyncHttpProvider.java:118)
at com
.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:506)
at org
.zendesk.client.v2.Zendesk.submit(Zendesk.java:1751)
at org
.zendesk.client.v2.Zendesk.access$1300(Zendesk.java:90)

Adam (Cloud Platform Support)

unread,
Feb 14, 2017, 5:49:56 PM2/14/17
to google-a...@googlegroups.com
URLFetchServiceStreamHandler extends HttpURLConnection, not HttpsURLConnection. You can use HttpURLConnection to connect to https:// URLs though. 

The issue is that zendesk-java-client relies on Ning's AsyncHttpClient 1.9.x which is doing things like this:

      if (request.getUri().getScheme().equals("https")) {
           
HttpsURLConnection secure = (HttpsURLConnection) urlConnection;

It would not work on App Engine without some modifications to the source code to avoid casting HttpURLConnection to HttpsURLConnection. Not all libraries will work on App Engine out of the box due to some quirks such as these

Shachar Grembek

unread,
Feb 15, 2017, 2:11:33 AM2/15/17
to Google App Engine
Thanks, but apparently it is used by a library that I using and therefore it makes things more complicated. Is there a workaround in matters of the technology stack that I am using that I can change so that the current implementation of that library wouldn't be an issue with the other stack. For example moving from Servlet based API to Google Endpoints or moving from App Engine to VM or Container?
BTW: I tried to edit the library code and update their usage

Adam (Cloud Platform Support)

unread,
Feb 17, 2017, 1:43:45 PM2/17/17
to Google App Engine
I should have mentioned this is specific to the App Engine standard environment - there aren't any sandbox restrictions on the flexible environment, so migrating to that is an option. 
Reply all
Reply to author
Forward
0 new messages