Google App Engine错误:java.lang.IllegalStateException:已提交

时间:2015-04-11 07:36:11

标签: google-app-engine

我已经向Google App Engine部署了一个应用程序,该应用程序每7秒轮询一次通知。该应用程序在本地运行完美,但它抛出此错误并返回null作为响应:

  

Google App Engine- java.lang.IllegalStateException:已提交

仅针对极少数请求抛出错误,并且大多数请求成功。

轮询请求到来时我一直使用的代码(我使用Objectify查询数据存储区):

@Override
protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    long uId = getLongParam(request, "uId");
    long timestamp = getLongParam(request, "ts");
    // Load notifications
    List<Notification> notifs = ofy().load().type(Notification.class).filter("uId", uId).list();

    // Update users
    updateUser(timestamp)

    // Send response as json
    setJsonResponse(response, new Gson().toJson(notifs));

    // Clear Objectify session cache
    ofy().clear();
}

private void updateUser(final long uId, final long timestamp) {
    ofy().transact(new Work<User>() {
        @Override
        public User run() {
            User user = ofy().load().type(User.class).id(uId).now();
            user.lastOnlineTime = timestamp;
            ofy().save().entity(user).now();
            return user;
        }
    });
}

完整堆栈跟踪:

java.lang.IllegalStateException: Committed
    at org.mortbay.jetty.Response.resetBuffer(Response.java:1024)
    at org.mortbay.jetty.Response.sendError(Response.java:240)
    at com.google.appengine.MyServlet.doGet(MyServlet.java:65)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    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.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
    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 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.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:254)
    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.headerComplete(HttpConnection.java:923)
    at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:527)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:745)

0 个答案:

没有答案