Android to Appengine RPC Nullponter on server
I have a Appengine connected Andorid project, to enable RPC calls between the server and the Android device. When I'm doing calls on the GWT client everything works perfectly, but when I'm doing calls from the Android app the server throws this nullpointer exception. I'm making RPC calls with a Requestfactory. GAE version 1.5.2
[ERROR] Unexpected error
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768)
at com.google.web.bindery.requestfactory.server.ServiceLayerCache.getOrCache(ServiceLayerCache.java:225)
at com.google.web.bindery.requestfactory.server.ServiceLayerCache.resolveRequestFactory(ServiceLayerCache.java:198)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:203)
at com.goog开发者_StackOverflowle.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:127)
at 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)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at 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: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(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:351)
at org.mortbay.jetty.handler.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.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
The problem is that the stack trace doesn't provide any information about some issues in my code.
What I want to do is to send an Exception from the Android Client to the AppEngine Server. So that's the android side code.
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... arg0) {
MyRequestFactory factory = (MyRequestFactory) Util
.getRequestFactory(context,
MyRequestFactory.class);
ExceptionRequest request = factory.exceptionRequest();
ExceptionProxy ep = request.create(ExceptionProxy.class);
ep.setClassName(aThrowable.getClass().getSimpleName());
ep.setRevision(1);
ep.setVersionName("2.1.2");
ep.setStack("");
request.updateException(ep).fire();
return null;
}
}.execute();
And that throws this exception (Internal Server Error)
09-05 22:29:36.104: ERROR/AndroidRuntime(602): Caused by: java.lang.RuntimeException: Internal Server Error
09-05 22:29:36.104: ERROR/AndroidRuntime(602): at com.google.web.bindery.requestfactory.shared.Receiver.onFailure(Receiver.java:44)
09-05 22:29:36.104: ERROR/AndroidRuntime(602): at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.fail(AbstractRequestContext.java:677)
09-05 22:29:36.104: ERROR/AndroidRuntime(602): ... 13 more
Doing RPC on the web client works perfectly but on the Android one I can't get it to work.
I encountered this and accidentally (I think) found an answer to it. Create a new AppEngine app (not a new App Engine Connected Android project, but literally going to appengine.google.com), and try testing it on your newly created app. I think they made some changes to AppEngine, and you need a new one to properly use App Engine Connected Android Project.
Best of luck!
It's because of the version of the GAE. Update it to 1.6.1.
In order to have an android app working with google app engine, you must create the App Engine connected Android project in Eclipse with GWT 2.3.0 configurated by default:
Windows -> Preferences -> Google -> Web Toolkit
(and not 2.4.0rc1)
If you try change the GWT version from 2.4.0rc1
to 2.3.0
after having created a project, you will always have this error with the android app (web app will work).
精彩评论