问题
I'm trying asynchronous processing support in servlet 3.1 with GAE J8 standard environment (no extensible environment).
Basically I have a servlet annotated with
@WebServlet(name = "MyServletName", urlPatterns = {"/dosomething"}, asyncSupported = true)
and to obtain an instance of AsyncContext I call (in doPost method)
final AsyncContext asyncContext = httpServletRequest.startAsync(httpServletRequest, httpServletResponse);
But asynchronous processing support seems to have some problems in GAE
Local development server says:
[INFO] GCLOUD: java.lang.IllegalStateException: !asyncSupported: _ah_DevAppServerModulesFilter
[INFO] GCLOUD: at org.eclipse.jetty.server.Request.startAsync(Request.java:2262)
[INFO] GCLOUD: at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:464)
[INFO] GCLOUD: at <my-servlet>.doPost
[INFO] GCLOUD: at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
[INFO] GCLOUD: at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1772)
[INFO] GCLOUD: at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:134)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.appengine.tools.development.jetty9.StaticFileFilter.doFilter(StaticFileFilter.java:122)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
[INFO] GCLOUD: at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
[INFO] GCLOUD: at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1751)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
[INFO] GCLOUD: at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
[INFO] GCLOUD: at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
[INFO] GCLOUD: at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
[INFO] GCLOUD: at com.google.appengine.tools.development.jetty9.DevAppEngineWebAppContext.doScope(DevAppEngineWebAppContext.java:94)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
[INFO] GCLOUD: at com.google.appengine.tools.development.jetty9.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:597)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
[INFO] GCLOUD: at org.eclipse.jetty.server.Server.handle(Server.java:534)
[INFO] GCLOUD: at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
[INFO] GCLOUD: at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
[INFO] GCLOUD: at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283)
[INFO] GCLOUD: at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108)
[INFO] GCLOUD: at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
[INFO] GCLOUD: at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
[INFO] GCLOUD: at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
[INFO] GCLOUD: at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
[INFO] GCLOUD: at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
[INFO] GCLOUD: at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
[INFO] GCLOUD: at java.lang.Thread.run(Thread.java:745)
Once the app is deployed to cloud, the error is:
java.lang.IllegalStateException: !asyncSupported: unknown
at org.eclipse.jetty.server.Request.startAsync (Request.java:2262)
at <my-servlet>.doPost
at javax.servlet.http.HttpServlet.service (HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service (HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle (ServletHolder.java:848)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1772)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter (ParseBlobUploadFilter.java:125)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1759)
at com.google.apphosting.runtime.jetty9.SaveSessionFilter.doFilter (SaveSessionFilter.java:37)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1759)
at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter (JdbcMySqlConnectionCleanupFilter.java:60)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1759)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter (TransactionCleanupFilter.java:48)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1759)
at org.eclipse.jetty.servlet.ServletHandler.doHandle (ServletHandler.java:582)
at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle (SecurityHandler.java:524)
at org.eclipse.jetty.server.session.SessionHandler.doHandle (SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle (ContextHandler.java:1180)
at org.eclipse.jetty.servlet.ServletHandler.doScope (ServletHandler.java:512)
at org.eclipse.jetty.server.session.SessionHandler.doScope (SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope (ContextHandler.java:1112)
at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:141)
at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.handle (AppVersionHandlerMap.java:297)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle (HandlerWrapper.java:134)
at org.eclipse.jetty.server.Server.handle (Server.java:534)
at org.eclipse.jetty.server.HttpChannel.handle (HttpChannel.java:320)
at com.google.apphosting.runtime.jetty9.RpcConnection.handle (RpcConnection.java:219)
at com.google.apphosting.runtime.jetty9.RpcConnector.serviceRequest (RpcConnector.java:81)
at com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest (JettyServletEngineAdapter.java:108)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest (JavaRuntime.java:657)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest (JavaRuntime.java:619)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run (JavaRuntime.java:589)
at com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run (JavaRuntime.java:783)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run (ThreadGroupPool.java:263)
at java.lang.Thread.run (Thread.java:745)
Have I missed something?
Thank you!
回答1:
According to https://cloud.google.com/appengine/docs/standard/java/release-notes#june_28_2017, async servlet 3.1 is not supported.
回答2:
I created a feature request on Google's public issue tracker, hope the App Engine team can implement this.
来源:https://stackoverflow.com/questions/45638360/servlet-asynchronous-processing-support-in-app-engine-java-8-standard-environmen