首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获取remoteApi GAE的超时

获取remoteApi GAE的超时
EN

Stack Overflow用户
提问于 2013-03-11 02:56:54
回答 1查看 486关注 0票数 0

我使用Java在Google中实现remoteAPi,方法是遵循本教程:https://developers.google.com/appengine/docs/java/tools/remoteapi

但是,在web.xml配置之后,我使用以下代码向本地数据存储插入新实体:

代码语言:javascript
复制
String username = "myusername";  
    String password = "mypassword";

    RemoteApiOptions options = new RemoteApiOptions()
        .server("localhost", 8888)  
        .credentials(username, password);
    RemoteApiInstaller installer = new RemoteApiInstaller();
    installer.install(options);

    try {
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        System.out.println("Key of new entity is " + 
            ds.put(new Entity("Hello Remote API!")));
    } finally {
        installer.uninstall();
    }

但出现了错误:

访问/远程应用程序/索引时出现问题。原因:

代码语言:javascript
复制
Timeout while fetching: http://localhost:8888/remote_api

我查看了调试,并知道它是由“installer.install(选项);”语句引起的。

我怎么才能解决这个问题?增加套接字超时时间?

提前感谢!

EN

回答 1

Stack Overflow用户

发布于 2013-03-21 06:09:57

我在本地和部署的apps.following代码中都这样做可能会对您有所帮助。请记住,代码必须用使用GWT2.4、JRE1.7和GAE1.7.2的编写。将GAE远程应用程序放入WEB/lib

web.xml

代码语言:javascript
复制
<servlet>
<display-name>Remote API Servlet</display-name>
<servlet-name>RemoteApiServlet</servlet-name>
<servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>RemoteApiServlet</servlet-name>
<url-pattern>/remote_api</url-pattern>
</servlet-mapping>

XyzServiceImpl.java

代码语言:javascript
复制
 @Override
public String callGaeRemote() {
    RemoteApiInstaller installer = null;
    List<Entity> allEntities = null;
    String response = null;

    try {


        RemoteApiOptions options = new RemoteApiOptions().server(
                "localhost", 8888).credentials(
                "username", "password");

        installer = new RemoteApiInstaller();
        installer.install(options);

         DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
            System.out.println("Key of new entity is " + 
                ds.put(new Entity("Hello Remote API!")));
        response = "Success";           
    } catch (IOException e) {
        e.printStackTrace();
    }
    finally {
        installer.uninstall();
    }
    return response;
}   
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15330483

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档