SpringBoot2.0 项目异常日志,但不影响运行(待解决)
第一种:
2019-04-17 01:46:33 [INFO] [org.apache.juli.logging.DirectJDKLog:175] - Error parsing HTTP request header Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level. java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:414) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:294) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)
第二种:
2019-04-18 02:08:43 [INFO] [org.apache.juli.logging.DirectJDKLog:175] - Error parsing HTTP request header Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level. java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986 at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:467) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:294) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)
第三种:
2019-04-18 02:44:42 [WARN] [org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver:197] - Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not parse 'Accept' header [/]: Invalid mime type "/": does not contain subtype after '/'] 2019-04-18 02:47:57 [WARN] [org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver:197] - Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not parse 'Accept' header [/]: Invalid mime type "/": does not contain subtype after '/'] 2019-04-18 05:26:21 [WARN] [org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver:197] - Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not parse 'Accept' header [/]: Invalid mime type "/": does not contain subtype after '/']
看下网上的解决方案:
(1)原因是Tomcat的header缓冲区大小不够,只需要在 server.xml 中增加 maxHttpHeaderSize 字段即可:
<Connector connectionTimeout="20000" maxHttpHeaderSize="10000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
我是在 SpringBoot 中的配置文件添加了:(并没有解决任何问题)
server.max-http-header-size=16KB
(2)头部包含了特殊字符的原因:
Tomcat 7.0.81以上支持,打开conf/catalina.properties在底部将
#tomcat.util.http.parser.HttpParser.requestTargetAllow=|
修改为
tomcat.util.http.parser.HttpParser.requestTargetAllow=|,{,}
目前服务经常不定时就挂了,没有错误日志。
先弄了个监控重启的脚本,还没找出根本原因:
#!/bin/bash while true do procnum=` ps -ef|grep "erp_server-1.0"|grep -v grep|wc -l` if [ $procnum -eq 0 ]; then nohup java -jar /srv/server/erp_server-1.0.jar & fi sleep 30 done