生成されたサンプルコードを使用してC2DMサンプルを実行することができます。ただし、Eclipseウィザードを使用して独自のRPCを実装しようとすると、エラーが発生しました。Android App Engine C2DM RPCエラー:操作用のRequestContextがありません
2012年1月17日11:19:13 PM com.google.web.bindery.requestfactory.server.ServiceLayerDecorator die SEVERE :予期しないエラー com.google.web.bindery.requestfactory:操作MG19Dafmkcg_3 $ 9lmRyrb_HKoK8 = 2012年1月17日午前11時19分13秒PM com.google.web.bindery.requestfactory.server.RequestFactoryServletのdoPost SEVEREなしRequestContextの。 server.UnexpectedException:操作なしRequestContextのMG19Dafmkcg_3 $ 9lmRyrb_HKoK8 = com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.die(ServiceLayerDecorator.java:216) でcom.google.web.bindery.requestfactory.serverで。 ResolverServiceLayer.resol veRequestContext(ResolverServiceLayer.java:154)com35.png FindServiceLayer.java:54) com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveRequestContext(ServiceLayerDecorator.java:162) (com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveRequestContext(ServiceLayerDecorator。 Javaの:162) sun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブメソッド) でsun.reflect.NativeMethodAccessorImpl.invoke(不明なソース) でsun.reflect.DelegatingMethodAccessorImpl.invoke(不明なソース) でjava.laでng.reflect.Method.invoke(Unknown Source) (com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:104) 、com.google.web.bindery.requestfactory.server) .ServiceLayerCache.getOrCache(ServiceLayerCache.java:233) (com.google.web.bindery.requestfactory.server.ServiceLayerCache.resolveRequestContext(ServiceLayerCache.java:187) 、com.google.web.bindery.requestfactory.server.ResolverServiceLayer com.google.web.bindery.requestfactory.server.FindServiceLayer.resolveRequestContextMethodで.resolveRequestContextMethod(ResolverServiceLayer.java:161)com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveRequestContextMethod(ServiceLayerDecorator.java:167)で (FindServiceLayer.java:70) (com.google.web.bindery.requestfactory) sun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブメソッド)でserver.ServiceLayerDecorator.resolveRequestContextMethod com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveRequestContextMethod(ServiceLayerDecorator.java:167)で(ServiceLayerDecorator.java:167) sun.reflect.NativeMethodAccessorImpl.invoke(不明なソース) at sun.reflect.DelegatingMethodAccessorImpl.invoke(不明なソース) at java.lang.reflect.Method.invoke(不明なソース) 、com.google.appengine.tools。 development.agent.runtime.Runtime.invoke(Runtime.java:104) (com.google.web.bindery.requestfactory.server.ServiceLayerCache.getOrCache(ServiceLayerCache.java:233) 、com.google.web.bindery) requestfactory.server.ServiceLayerCache.resolveReques (サービスレンタルサーバー) SimpleRequestProcessor.java:225) (com.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:127) 、com.google.web.bindery.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet。 java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax。servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter (ServletHandler.java:1166) at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35) at org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157) COMでorg.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157) でcom.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60) で 。 google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43) at org.mortbay.jetty.serv .ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157) com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122) at org.mortbay.jetty.servlet.ServletHandler $ CachedChain。 doFilter(ServletHandler.java:1157) at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97) at org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:97) 1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty。 servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHa ndler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) com.google.appengine.tools.development.JettyContainerService $ ApiProxyHandler.handle(JettyContainerService.java:362) at org.mortbay.jetty。 .handlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection $ RequestHandler.content(HttpConnection.java:938) at org.mortbay.jetty.H ORGでorg.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) でorg.mortbay.jetty.HttpParser.parseAvailableでttpParser.parseNext(HttpParser.java:755) (HttpParser.java:218) 。 org.mortbay.thread.QueuedThreadPool $ PoolThread.run(QueuedThreadPool.java:582)でmortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
私のエンティティは次のとおりです。
package com.serene.receiptninja.server;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class SyncEvent {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String message;
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message+" Sent from my app engine.";
}
public Long getId() {
return id;
}
}
リクエスト:
package com.serene.receiptninja.shared;
import java.util.List;
import com.google.web.bindery.requestfactory.shared.Request;
import com.google.web.bindery.requestfactory.shared.RequestContext;
import com.google.web.bindery.requestfactory.shared.ServiceName;
@ServiceName(value = "com.serene.receiptninja.server.SyncEventService", locator = "com.serene.receiptninja.server.SyncEventServiceLocator")
public interface SyncEventRequest extends RequestContext {
Request<SyncEventProxy> createSyncEvent();
Request<SyncEventProxy> readSyncEvent(Long id);
Request<SyncEventProxy> updateSyncEvent(SyncEventProxy syncevent);
Request<Void> deleteSyncEvent(SyncEventProxy syncevent);
Request<List<SyncEventProxy>> querySyncEvents();
}
プロキシ:
パッケージcom.serene.receiptninja。共有;
import com.google.web.bindery.requestfactory.shared.ProxyForName;
import com.google.web.bindery.requestfactory.shared.ValueProxy;
@ProxyForName(value = "com.serene.receiptninja.server.SyncEvent", locator = "com.serene.receiptninja.server.SyncEventLocator")
public interface SyncEventProxy extends ValueProxy {
void setMessage(String message);
String getMessage();
Long getId();
}
はRequestFactory:
import com.google.web.bindery.requestfactory.shared.InstanceRequest;
import com.google.web.bindery.requestfactory.shared.Request;
import com.google.web.bindery.requestfactory.shared.RequestContext;
import com.google.web.bindery.requestfactory.shared.RequestFactory;
import com.google.web.bindery.requestfactory.shared.ServiceName;
import com.serene.receiptninja.shared.MessageProxy;
import com.serene.receiptninja.shared.RegistrationInfoProxy;
import com.serene.receiptninja.shared.SyncEventRequest;
public interface MyRequestFactory extends RequestFactory {
@ServiceName("com.serene.receiptninja.server.HelloWorldService")
public interface HelloWorldRequest extends RequestContext {
/**
* Retrieve a "Hello, World" message from the server.
*/
Request<String> getMessage();
}
@ServiceName("com.serene.receiptninja.server.RegistrationInfo")
public interface RegistrationInfoRequest extends RequestContext {
/**
* Register a device for C2DM messages.
*/
InstanceRequest<RegistrationInfoProxy, Void> register();
/**
* Unregister a device for C2DM messages.
*/
InstanceRequest<RegistrationInfoProxy, Void> unregister();
}
@ServiceName("com.serene.receiptninja.server.Message")
public interface MessageRequest extends RequestContext {
/**
* Send a message to a device using C2DM.
*/
InstanceRequest<MessageProxy, String> send();
}
HelloWorldRequest helloWorldRequest();
RegistrationInfoRequest registrationInfoRequest();
MessageRequest messageRequest();
SyncEventRequest syncEventRequest();
}
のAndroidコード:
final SyncEventRequest request = requestFactory.syncEventRequest();
request.createSyncEvent().fire(new Receiver <SyncEventProxy>(){
@Override
public void onSuccess(SyncEventProxy arg0) {
// TODO Auto-generated method stub
message = arg0.getMessage();
}
});