天天看點

13.8 java.lang.IllegalArgumentException: Request header is too large13.8 java.lang.IllegalArgumentException: Request header is too large問題日志:java.lang.IllegalArgumentException: Request header is too large解決方案原因分析:解決方案

13.8 java.lang.IllegalArgumentException: Request header is too large

問題日志:java.lang.IllegalArgumentException: Request header is too large

java.lang.IllegalArgumentException: Request header is too large
    at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:701)
    at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:455)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:667)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)


           

解決方案

配置 tomcat server xml

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" maxHttpHeaderSize="65536" maxPostSize="4194304"  
               URIEncoding="UTF-8"/>

           

org.apache.coyote.http11.AbstractHttp11Protocol

原因分析:

在tomcat的org.apache.coyote.http11.AbstractHttp11Protocol類中定義了其預設值:

/**
     * Maximum size of the HTTP message header.
     */
    private int maxHttpHeaderSize = 8 * 1024;

           

是以,當請求頭大于 8 * 1024,就會報錯。針對這樣的大資料量的請求,需要單獨配置這個maxHttpHeaderSize的值。

在application.properties裡面配置一下maxHttpHeaderSize的值:

server.max-http-header-size=1048576
# Maximum number of connections that the server will accept and process at any given time.
server.tomcat.max-connections= 3000
# Maximum size in bytes of the HTTP post content.
server.tomcat.max-http-post-size=1048576
# Maximum amount of worker threads.
server.tomcat.max-threads=1000
           

參考:

http://tomcat.apache.org/tomcat-8.0-doc/config/ajp.html