The request associated with the AsyncContext has already completed processing

Some time ago there was a problem with the servlet3.0, is in servlet in asynchronous processing data, due to time outs, dry method terminates, but the back throws, anomalies are as follows:

java.lang.IllegalStateException: The request associated with the AsyncContext has already completed processing.
     at org.apache.catalina.core.AsyncContextImpl.check(AsyncContextImpl.java:521)
     at org.apache.catalina.core.AsyncContextImpl.getResponse(AsyncContextImpl.java:245)  

Appeared and the reason for this is because asynchronous processing time servlet the default is 10 seconds, apparently because the data is too large, resulting in time out.

The solution is simple only in the doPost method of servlet add a sentence

asyncContext.setTimeout(900000000);

For asynchronous loading manual setting the timeout can be, all the code as follows:

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType(getServletContext().getInitParameter("content"));
		//In asynchronous mode, call the business processing threads to process business
        //Servlet will not be blocked, but directly to the execution
        //Business processing after the completion of the response by the AsyncContext management
        AsyncContext asyncContext = request.startAsync();
        asyncContext.setTimeout(900000000);
        ProductHandleThread productHandleThread = new ProductHandleThread(asyncContext,request.getSession());
        asyncContext.start(productHandleThread);
	}

  

时间: 2024-11-06 11:33:46

The request associated with the AsyncContext has already completed processing的相关文章

Servlet 3特性:异步Servlet

本文由 ImportNew - 彭秦进 翻译自 journaldev.欢迎加入翻译小组.转载请见文末要求. 理解异步Servlet之前,让我们试着理解为什么需要它.假设我们有一个Servlet需要很多的时间来处理,类似下面的内容: LongRunningServlet.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

arcgis server "System.Web.Services.Protocols.SoapException: Error processing server request".

在 Arcgis Server 10中创建第一个程序,运行的时候就报错:System.Web.Services.Protocols.SoapException: Error processing server request 详细信息: Server Error in '/' Application. Error processing server request Description: An unhandled exception occurred during the execution

RequestDispatcher的request方法和include方法有什么不同

都表示要跳转到其他资源,不同的是,如果使用forward跳转则后面的response输出则不会执行,而用include来跳转,则include的servlet执行完后,再返回到原来的servlet执行response的输出(如果有).如:servlet ARequestDispatcher disp = request.getRequestDispatcher("B");disp.forward(request, response);System.out.println("s

Spring 4 官方文档学习 Web MVC 框架

1.介绍Spring Web MVC 框架 Spring Web MVC 框架是围绕DispatcherServlet设计的,所谓DispatcherServlet就是将请求分发到handler,需要有配置好的handler映射.视图解析.本地化.时区.theme解决方案.还有上传文件的支持.默认的handler是基于@Controller和@RequestMapping注解.自Spring 3.0 起,@Controller注解还能用于RESTful,需要配合@PathVariable以及其他

第二章 Servlet 接口(JavaTM Servlet 规范3.1 )

Servlet 接口 Servlet 接口是 Java Servlet API 的核心抽象.所有 servlet 要么直接要么间接地实现该接口,通过扩展一个类实现此接口.在 Java Servlet API 中有两个类 GenericServlet 和 HttpServlet 实现了此 Servlet 接口.为了更多目的,开发者将扩展 HttpServlet 来实现他们的 servlet. 2.1 请求处理方法 为处理客户端请求,基础 Servlet 接口定义了一个 service 方法.ser

深入剖析Tomcat-第二章:一个简单的servlet容器(1)

内容:在上一章的基础上多了对servlet的处理,重点是ServletProcessor1这个类,利用到了URL.URLClassLoader(可以参看文档)和java反射机制. webroot: public class HttpServer1 { private static final String SHUTDOWN_COMMAND = "/SHUTDOWN"; private boolean shutdown = false; public void await() { Ser

Java EE之Servlet技术

Java EE之Servlet技术 java Servlet介绍 Java Servlet是java EE标准规范之一.Servlet是Java Web 技术的核心基础, 因此掌握好Servlet是很有必要的.掌握Servlet的工作原理是成为一名合格的 Java Web技术开发人员的基本要求. Servlets are very important topic of Java EE and all of the web applications framework such as Spring

day21-基础加强

day21基础加强 今日内容 l 泛型 l 注解 l Servlet3.0 l 动态代理 l 类加载器 泛型 1 回顾泛型类 泛型类:具有一个或多个泛型变量的类被称之为泛型类. public class A<T> { private T t; public A(T t) { this.t = t; } public T get() { return t; } } 2 泛型方法 泛型方法的特点: l 方法的参数中会使用泛型变量: l 方法的返回值中会使用泛型变量. public <T>

servlet3.0 异步处理

转:https://blog.csdn.net/benjamin_whx/article/details/38874657 13.1.概述 计算机的内存是有限的.Servlet/JSP容器的设计者很清楚这一点,因此他们提供了一些可以进行配置的设置,以确保容器能够在宿主机器中正常运行.例如,在Tomcat7中,处理进来请求的最多线程数量为200.如果是多处理器的服务器,则可以放心地增加线程数量,不过建议你还是尽量使用这个默认值. Servlet或Filter一直占用着请求处理线程,直到它完成任务.