embed tomcat bug:org.apache.catalina.connector.CoyoteAdapter checkRecycled

原创 2017年08月02日 16:39:00

1.异常报错:

 org.apache.catalina.connector.CoyoteAdapter checkRecycled
信息: Encountered a non-recycled response and recycled it forcedly.
org.apache.catalina.connector.CoyoteAdapter$RecycleRequiredException
    at org.apache.catalina.connector.CoyoteAdapter.checkRecycled(CoyoteAdapter.java:632)
    at org.apache.coyote.http11.AbstractHttp11Processor.recycle(AbstractHttp11Processor.java:1821)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.release(Http11Protocol.java:140)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:720)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

2.解决
1)查看报错源码

 @Override
    public void checkRecycled(org.apache.coyote.Request req,
            org.apache.coyote.Response res) {
        Request request = (Request) req.getNote(ADAPTER_NOTES);
        Response response = (Response) res.getNote(ADAPTER_NOTES);
        String messageKey = null;
        if (request != null && request.getHost() != null) {
            messageKey = "coyoteAdapter.checkRecycled.request";
        } else if (response != null && response.getContentWritten() != 0) {
            messageKey = "coyoteAdapter.checkRecycled.response";
        }
        if (messageKey != null) {
            // Log this request, as it has probably skipped the access log.
            // The log() method will take care of recycling.
            log(req, res, 0L);

            if (connector.getState().isAvailable()) {
                if (log.isInfoEnabled()) {
                    log.info(sm.getString(messageKey),
                            new RecycleRequiredException());
                }
            } else {
                // There may be some aborted requests.
                // When connector shuts down, the request and response will not
                // be reused, so there is no issue to warn about here.
                if (log.isDebugEnabled()) {
                    log.debug(sm.getString(messageKey),
                            new RecycleRequiredException());
                }
            }
        }
    }

报错点是由这个判断导致: response != null && response.getContentWritten() != 0


public long getContentWritten() {
        return outputBuffer.getContentWritten();
    }

  public long getContentWritten() {
        return bytesWritten + charsWritten;
    }

由于HttpServlet实现类中处理post请求时有调用过HttpServletResponse类的getWriter().write()和flush()方法,间隔20秒后在又使用了同一个对象的getWriter().write()和flush()方法,导致判断异常报错


上面的逻辑还会出现另外一个BUG

java.lang.NullPointerException: null
    at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:216) ~[tomcat-embed-core-7.0.73.jar:7.0.73]
    at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480) ~[tomcat-embed-core-7.0.73.jar:7.0.73]
    at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:120) ~[tomcat-embed-core-7.0.73.jar:7.0.73]
    at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:800) ~[tomcat-embed-core-7.0.73.jar:7.0.73]
    at org.apache.coyote.Response.action(Response.java:172) ~[tomcat-embed-core-7.0.73.jar:7.0.73]
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:366) ~[tomcat-embed-core-7.0.73.jar:7.0.73]
    at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:334) ~[tomcat-embed-core-7.0.73.jar:7.0.73]
    at org.apache.catalina.connector.CoyoteWriter.flush(CoyoteWriter.java:98) ~[tomcat-embed-core-7.0.73.jar:7.0.73]
    at com.joymeng.domain.system.tools.web.WaitingHttpResponse.flushReponse(WaitingHttpResponse.java:43) [bin/:?]
    at com.joymeng.domain.system.tools.web.WebService.timeoutWaitingHttpResponse(WebService.java:113) [bin/:?]
    at com.joymeng.domain.system.tools.web.WebService.tick(WebService.java:98) [bin/:?]
    at com.joymeng.domain.world.thread.SecondExecuteRunable.run(SecondExecuteRunable.java:15) [bin/:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.7.0_45]
    at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [?:1.7.0_45]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [?:1.7.0_45]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:1.7.0_45]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.7.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.7.0_45]
    at java.lang.Thread.run(Unknown Source) [?:1.7.0_45]
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

org.apache.catalina.connector.Request.parseParameters(Request.java:2446) NullPointerException异常处理

1、环境 tomcat6.0.8 + jdk6 + struts1  2、问题的产生 页面有两个异常的请求 http://127.0.0.1/project/a.action?do=t...
  • p_3er
  • p_3er
  • 2014年05月07日 14:20
  • 2162

org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe

完整错误信息:org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe at org....

org.apache.catalina.connector.ClientAbortException: java.io.IOException: 您的主机中的软件中止了一个已建立的连接

2017-01-04 13:56:06.216 ERROR 6800 --- [http-nio-8082-exec-3] o.a.c.c.C.[Tomcat].[localhost]        ...

struts2 启动tomcat时报错:org.apache.catalina.core.StandardContext filterStart

用struts2+jsp做个网站,到了网站制作后期时,启动tomcat竟然无法启动,挂了。之前一直有用可是今天添加了一些东西就挂了,删除之后还是无法启动tomcat服务器。 下面是报错的代码: or...

session自定义存储,如何更好地进行session共享;读tomcat7源码,org.apache.catalina.session.FileStore可知

session自定义存储,如何更好地进行session共享; 读tomcat源码,org.apache.catalina.session.FileStore可知 详见: 方法1 public ...

Tomcat 7.0.12 报错 org.apache.catalina.deploy.WebXml addFilter

今天工作的时候从SVN新下载了一个项目,用的Tomcat 7.0.52 启动的,虽然项目能启动,但是有些页面报java.io.FileNotFoundException: Could not reso...

tomcat启动报错“java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addFilter”

java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addFilter at org.apache.tomcat.u...
  • zjsdrs
  • zjsdrs
  • 2017年01月12日 09:16
  • 266

Tomcat部署项目时出错java.lang.IllegalStateException: ContainerBase.addChild: start:org.apache.catalina.Life

Tomcat部署项目时出错java.lang.IllegalStateException: ContainerBase.addChild: start:org.apache.catalina.Life...

tomcat 启动 maven 报错 org.apache.catalina.LifecycleException

问题1:tomcat不识别maven工程 解决办法:project右击->Properties->Project Facets,选择Dynamic Web Module及其版本(tomcat6.x支...
  • rugaxm
  • rugaxm
  • 2017年07月21日 18:12
  • 246

Tomcat启动报错: : org.apache.catalina.LifecycleException

Root Cause: 工程依赖包由Maven管理下载,默认maven的远程repository server下载有时中断,导致Maven下载的jar包存在问题。解决方案: 1. 从新配置maven的...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:embed tomcat bug:org.apache.catalina.connector.CoyoteAdapter checkRecycled
举报原因:
原因补充:

(最多只允许输入30个字)