使用tomcat 7.0.73的long轮询得到cometd 3.0.1的以下错误。我们还没有在tomcat 7.0.50中看到这个问题。

来自CometD开发人员


  javax.servlet.ServletRequestWrapper.getAsyncContext(ServletRequestWrapper.java:418)
  org.cometd.server.transport.AbstractStreamHttpTransport.process(AbstractStreamHttpTransport.java:88)


这是CometD在暂停它后继续进行长时间轮询的原因,因此
调用getAsyncContext()是完全合法的,这就是Tomcat
抱怨。

有没有办法让Tomcat进行长时间轮询?

Time: Fri Mar 24 2017 17:46:55 GMT+0530 (India Standard Time) Channel: null Reason: Error occured during CometD connect.
Failure Message: {"id":"4","successful":false,"channel":"/meta/connect","failure":{"reason":"error","exception":"Internal Server Error","httpCode":500,"connectionType":"long-polling","transport":{"readyState":4,"withCredentials":true,"responseText":"

HTTP Status 500 - java.lang.RuntimeException: java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
type Exception report

message java.lang.RuntimeException: java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.lang.RuntimeException: java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)\n\tcom.googlecode.psiprobe.Tomcat70AgentValve.invoke(Tomcat70AgentValve.java:38)\n\torg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)\n\torg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)\n\torg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)\n\torg.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:317)\n\torg.apache.coyote.http11.AbstractHttp11Processor.asyncDispatch(AbstractHttp11Processor.java:1681)\n\torg.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:616)\n\torg.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1756)\n\torg.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1715)\n\tjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\torg.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n\tjava.lang.Thread.run(Thread.java:745)\n
root cause

java.lang.RuntimeException: java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)\n\tcom.googlecode.psiprobe.Tomcat70AgentValve.invoke(Tomcat70AgentValve.java:38)\n\torg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)\n\torg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)\n\torg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)\n\torg.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:317)\n\torg.apache.coyote.http11.AbstractHttp11Processor.asyncDispatch(AbstractHttp11Processor.java:1681)\n\torg.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:616)\n\torg.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1756)\n\torg.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1715)\n\tjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\torg.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n\tjava.lang.Thread.run(Thread.java:745)\n
root cause

java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)\n\torg.apache.catalina.connector.Request.getAsyncContext(Request.java:1740)\n\torg.apache.catalina.connector.RequestFacade.getAsyncContext(RequestFacade.java:1047)\n\tjavax.servlet.ServletRequestWrapper.getAsyncContext(ServletRequestWrapper.java:418)\n\torg.cometd.server.transport.AbstractStreamHttpTransport.process(AbstractStreamHttpTransport.java:88)\n\torg.cometd.server.transport.AbstractStreamHttpTransport.handle(AbstractStreamHttpTransport.java:61)\n\torg.cometd.server.CometDServlet.service(CometDServlet.java:103)\n\tjavax.servlet.http.HttpServlet.service(HttpServlet.java:731)\n
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.73 logs.

Apache Tomcat/7.0.73

","status":500,"statusText":"Internal Server Error"},"message":{"channel":"/meta/connect","connectionType":"long-polling","id":"4","clientId":"a10paginvut3d5yfwc3azxjvpa","ext":{"ack":-1}}}}

最佳答案

根据https://groups.google.com/forum/#!topic/cometd-users/92AiWQF5DdU,此问题已在https://github.com/cometd/cometd/issues/557中修复。

10-08 18:17