应用引擎代码中的权限被拒绝错误

时间:2016-03-07 07:11:38

标签: google-app-engine

在localhost和cloud中执行应用引擎代码时,我在第5行收到以下错误。

1   HttpClient client = new HttpClient();
2       GetMethod getMethod =new GetMethod(url);
3       client.getHttpConnectionManager().getParams()
4       .setConnectionTimeout(1000);
5       int response = client.executeMethod(getMethod);

我在localhost和app引擎中运行作业时看到此错误。

请查看以下错误日志:

INFO] 2016-03-07 11:04:03 DEBUG HttpConnection:1215 - enter HttpConnection.closeSockedAndStreams()
[INFO] 2016-03-07 11:04:03 INFO  HttpMethodDirector:439 - I/O exception (java.net.SocketException) caught when processing request: Permission denied: Not allowe
d to issue a socket bind: permission denied.
[INFO] 2016-03-07 11:04:03 DEBUG HttpMethodDirector:443 - Permission denied: Not allowed to issue a socket bind: permission denied.
[INFO] java.net.SocketException: Permission denied: Not allowed to issue a socket bind: permission denied.
[INFO]  at com.google.appengine.api.socket.SocketApiHelper.translateError(SocketApiHelper.java:95)
[INFO]  at com.google.appengine.api.socket.SocketApiHelper.translateError(SocketApiHelper.java:106)
[INFO]  at com.google.appengine.api.socket.SocketApiHelper.makeSyncCall(SocketApiHelper.java:74)
[INFO]  at com.google.appengine.api.socket.AppEngineSocketImpl.createSocket(AppEngineSocketImpl.java:470)
[INFO]  at com.google.appengine.api.socket.AppEngineSocketImpl.bind(AppEngineSocketImpl.java:486)
[INFO]  at java.net.Socket.bind(Socket.java:631)
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[INFO]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO]  at java.lang.reflect.Method.invoke(Method.java:606)
[INFO]  at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:130)
[INFO]  at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:139)
[INFO]  at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:125)
[INFO]  at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
[INFO]  at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
[INFO]  at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
[INFO]  at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
[INFO]  at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
[INFO]  at com.disney.unityads.UnityAdsStats.downloadZip(UnityAdsStats.java:169)
[INFO]  at com.disney.unityads.UnityAdsStats.run(UnityAdsStats.java:72)
[INFO]  at com.disney.unityads.UnityAdsChannelJobWorker.doPost(UnityAdsChannelJobWorker.java:46)
[INFO]  at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
[INFO]  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[INFO]  at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
[INFO]  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)

1 个答案:

答案 0 :(得分:1)

查看文档以了解如何发出HTTP请求。 AppEngine是一个非常有限的环境,例如,如果您尝试使用备用HTTP客户端,您的应用程序将获得与尝试直接使用套接字的应用程序相同的处理方式。

https://cloud.google.com/appengine/docs/java/urlfetch/