Tag: google app engine

java,驱动APIv2,appengine 1.7.3,struts2.3.4.1,OAuth2。 TokenResponseException:400 OK invalid_grant

我收到错误invalid_grant我已经看过googleing arround,但是在这个问题已经有几天了。 错误被抛入: File file = insert.execute(); 我只是想从我的webapp上传文件到google驱动器。 我正在使用服务帐户在API Access(https://code.google.com/apis/console/)中生成的私钥对(.p12): Service account Use service accounts to call Google APIs on behalf of your application instead of an end-user. Learn more Client ID: xxx-xxxxxx.apps.googleusercontent.com Email address: xxx-xxxxxxxxxxx@developer.gserviceaccount.com Public key fingerprints: a108d8713103e09d0013655c9f80458f03e3a38a – Delete… 在Google APis – >驱动SDK(https://code.google.com/apis/console/?api=drive#project:347347146680:drive_sdk)中,我已将此ClientID放入: Drive Integration OAuth Client ID (Required) Enter the Client […]

在Google App Engine JAVA中创建多个实例

我正在使用JAVA测试Google App Engine,我想测试并行运行多个实例。 但是,我不知道如何激活多个实例。 我尝试在不同的浏览器中运行这个Servlet(我也尝试在不同的机器上运行并发调用 – 使用不同的IP) import java.io.IOException; import javax.servlet.*; import javax.servlet.http.*; import java.math.*; public class SimpleServlet extends HttpServlet { //A variable that is NOT thread-safe! public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doPost(req, resp); } public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { int counter = 0; resp.getWriter().println(“”); […]

使用来自计算引擎和/或外部网络的SSL的Google Cloud SQL

我正在尝试使用SSL连接到Google Cloud SQL(mysql)实例。 我已经启用了两个IP地址和一个具有远程访问权限的用户来自这些IP地址。 我还从Google的开发者控制台生成了证书文件。 client-key.pem client-cert.pem server-ca.pem 从两个启用的IP地址中的每一个使用此命令,我成功建立了连接。 mysql –ssl-ca=server-ca.pem –ssl-cert=client-cert.pem –ssl-key=client-key.pem –host=xxx.xxx.xxx.xxx –user=username –password 由于mysql客户端正常工作,我知道我的防火墙设置,用户,证书等都已正确设置。 现在我想在可执行jar文件中与java建立类似的连接。 按照此处列出的步骤操作: http : //dev.mysql.com/doc/connector-j/en/connector-j-reference-using-ssl.html Step 1: keytool -import -alias mysqlServerCACert -file cacert.pem -keystore truststore 注意:我将server-ca.pem替换为说明中使用的cacert.pem Step 2: openssl x509 -outform DER -in client-cert.pem -out client.cert Step 3: keytool -import -file client.cert -keystore keystore -alias mysqlClientCertificate 这些步骤创建了我的密钥库和信任库文件。 我在生成这两个文件时为每个文件关联不同的密码。 […]

用于POST请求的HttpURLConnection App Engine Java示例不起作用

我正在尝试在app引擎应用程序下使用urlfetch执行POST请求。 我已按照“使用HttpURLConnection”部分下的App Engine文档(此处为https://developers.google.com/appengine/docs/java/urlfetch/usingjavanet )中的简单示例提取的说明(和代码)进行了操作。 。 import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStreamWriter; String message = URLEncoder.encode(“my message”, “UTF-8”); try { URL url = new URL(“http://httpbin.org/post”); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestMethod(“POST”); OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream()); writer.write(“message=” + message); writer.close(); if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { […]

将XML转换为对象的最佳方法

我正在使用Java在Google App Engine上创建一个应用程序,该应用程序接受标准XML文件并将其映射到对象,然后将其保存到数据存储区。 我期待相当多的条目/天(大约500+)..考虑到CPU和GAE / j的数据配额的成本,串行化xml的最佳方式是什么?

使用Oauth将Java应用程序与GAE应用程序连接起来

我有一个Java应用程序和一个GAE应用程序,它将C2DM消息发送到Android设备。 现在我想让java应用程序的用户能够通过他们的Google帐户登录到GAE应用程序。 我是否正确,我需要使用oauth来实现这一点? 一点点背景: +———–+ +———-+ | JAVA App | send Message to —> | GAE App | +———–+ +———-+ ^ | | Notify Client | —————————- | | [YES] —> Start delivering C2DMessage 我希望我的ASCII图片更容易理解;) 不知何故,我需要允许用户使用他们的google凭据登录java应用程序,如果我向服务器发送消息,则将用户数据与消息一起发送到服务器。 我真的不知道如何做到这一点。 如果你能告诉我,那么我是在正确或错误的轨道上会很棒。 任何建议我都会很高兴。 谢谢,马克

使用SpreadSheet API时无法完成HTTP请求

我正在开发一个Google App Engine应用程序,它可以读取和编辑一个包含大约150列和500行的大型SpreadSheet。 除了特定的大小(它可能会有所不同),我正在寻找一种提高性能的方法,因为大多数时候我得到500内部服务器错误(如下所示)。 java.lang.RuntimeException:无法完成HTTP请求由以下原因引起:java.net.SocketTimeoutException:获取URL时超时: https : //spreadsheets.google.com/feeds/worksheets/xxxxxxxxxxxxxxxxxxxxxxx/private/full 在下面的代码片段中,您可以看到我如何阅读我的SpreadSheet以及哪一行抛出exception。 for (SpreadsheetEntry entry : spreadsheets) { if (entry.getTitle().getPlainText().compareTo(spreadsheetname) == 0) { spreadsheet = entry; } } WorksheetFeed worksheetFeed = service.getFeed(spreadsheet.getWorksheetFeedUrl(), WorksheetFeed.class); List worksheets = worksheetFeed.getEntries(); WorksheetEntry worksheet = worksheets.get(0); URL listFeedUrl = worksheet.getListFeedUrl(); // The following line is the one who generates the error ListFeed listFeed […]

objectify-appengine – 嵌入式类 – 不是受支持的属性类型

我正在谷歌应用引擎上尝试objectify(版本2.2.3)嵌入式类示例(wiki)。 我收到此错误: java.lang.IllegalArgumentException:one:com.mypkg.LevelOne不是受支持的属性类型。 在com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:184) 我的代码与Wiki中的代码相同。 控制器中的部分: EntityWithEmbedded ent = new EntityWithEmbedded(); ent.one = new LevelOne(); ent.one.foo =“Foo Value”; ent.one.two = new LevelTwo(); ent.one.two.bar =“条形值”; EntityWithEmbedded类: import javax.jdo.annotations.Embedded; import javax.persistence.Entity; import javax.persistence.Id; @实体 公共类EntityWithEmbedded { @Id public Long id; @Embedded public LevelOne one; // getter&setters here } class级一级: import javax.persistence.Embedded; 公共课LevelOne { public String foo; public […]

用Objectify查询Geopt

我最难用Objectify查询GeoPt字段。 我确定有关于GeoPt字段的@Index注释。 但是,以下声明似乎不起作用 ofy().load() .type(GeoStat.class) .filter(“geoPt.latitude >=”, neLat) .limit(10); 在Objectify中查询GeoPt字段是否可行?

如何避免GoogleAppEngine DataStore延迟?

我是App Engine的新手并编写了一个示例App。 如果我创建或更新实体: Entity record = new Entity(…); … set properties DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); datastore.put(record); 然后重定向到显示新的或更新的实体的页面 resp.sendRedirect(“MainPage.jsp”); 执行以下代码的位置 DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Query query = new Query(…).addSort(…, Query.SortDirection.DESCENDING); List entities = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(20)); 新记录不在列表中。 页面已更新(如显示的时间戳所示),但新记录或现有记录的修改仅在刷新页面后延迟几秒钟后显示。 如何避免这种情况? DataStore可能不适合这样的事情吗? 我正在使用GAE的Eclipse本地测试环境和Windows XP 64。