错误信息:
2017-1-17 10:09:39 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet springServlet threw exception
java.lang.ArrayIndexOutOfBoundsException: 8192
at org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:735)
at org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:646)
at org.apache.coyote.http11.InternalOutputBuffer.sendHeader(InternalOutputBuffer.java:519)
at org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1653)
at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:958)
at org.apache.coyote.Response.action(Response.java:184)
at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:591)
at org.apache.coyote.Response.doWrite(Response.java:533)
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:364)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:339)
at org.apache.tomcat.util.buf.IntermediateOutputStream.write(C2BConverter.java:242)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:263)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:106)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:116)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:203)
at org.apache.tomcat.util.buf.C2BConverter.convert(C2BConverter.java:87)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:468)
at org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:162)
at org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:171)
at org.apache.catalina.connector.CoyoteWriter.print(CoyoteWriter.java:221)
at kingtool.HttpTool.writeInfo(HttpTool.java:218)
at com.bobo.code.web.controller.WebPltmConfController.connect(WebPltmConfController.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
2017-1-17 10:09:39 org.apache.coyote.http11.Http11Processor process
严重: Error processing request
java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:706)
at org.apache.coyote.http11.InternalOutputBuffer.sendStatus(InternalOutputBuffer.java:443)
at org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1640)
at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:958)
at org.apache.coyote.Response.action(Response.java:186)
at org.apache.coyote.Response.sendHeaders(Response.java:382)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:314)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:296)
at org.apache.catalina.connector.Response.flushBuffer(Response.java:549)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:344)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:286)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
2017-1-17 10:09:39 org.apache.coyote.http11.Http11Processor process
严重: Error finishing response
java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:706)
at org.apache.coyote.http11.InternalOutputBuffer.sendStatus(InternalOutputBuffer.java:443)
at org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1640)
at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:958)
at org.apache.coyote.Response.action(Response.java:184)
at org.apache.coyote.http11.InternalOutputBuffer.endRequest(InternalOutputBuffer.java:403)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:903)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
解决方案:
在weblogic下一模一样的代码,没有报错,tomcat却报错了,所以就怀疑是tomcat server本身存在问题.
一番百度后, 原来是tomcat默认的maxHttpHeaderSize只有8192,而我cookie放了大报文,导致head头信息量过大,无法存放.
在<connector> 节点中添加 maxHttpHeaderSize="81920" 解决问题,如下 :
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" maxHttpHeaderSize="81920"/>
最终发现<Connector中还可以配置最大线程 maxThreads="250" 超时时间connectionTimeout="20000" 等