0

このチュートリアルに従って、Javaを使用してGoogle App Engine(GAE)にremoteAPiを実装しています: https ://developers.google.com/appengine/docs/java/tools/remoteapi

しかし、web.xmlで構成した後、次のコードを使用して新しいエンティティをローカルデータストアに挿入します。

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();
    }

しかし、エラーが発生しました:

/ remoteApi/indexへのアクセスに問題があります。理由:

Timeout while fetching: http://localhost:8888/remote_api

デバッグを確認したところ、「installer.install(options);」が原因であることがわかりました。声明。

どうすればこれを解決できますか?ソケットのタイムアウトを増やしますか?

少し早いですがお礼を !

4

1 に答える 1

0

私はローカルと展開されたapps.followingコードの両方でそれを行いました. コードはRPCで書く必要があることを覚えておいてください 。私はGWT 2.4、JRE 1.7、およびGAE 1.7.2を使用しました。GAE Remote Api を WEB-INF/lib に配置します。

web.xml

<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

 @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;
}   
于 2013-03-21T06:09:57.337 に答える