服务器:[http-nio-8080-exec-7] org.apache.coyote.http11.Http11Processor.service 处理请求时出错 java.lang.NullPo
Posted
技术标签:
【中文标题】服务器:[http-nio-8080-exec-7] org.apache.coyote.http11.Http11Processor.service 处理请求时出错 java.lang.NullPointerException【英文标题】:Server: [http-nio-8080-exec-7] org.apache.coyote.http11.Http11Processor.service Error processing request java.lang.NullPointerException 【发布时间】:2017-06-01 03:29:23 【问题描述】:我的tomcat服务器总是抛出以下错误(在linux下,Tomcat版本是8.5.4,使用tail -f catalina.out):
第一个错误:
17-Jan-2017 10:39:24.982 SEVERE [http-nio-8080-exec-7] org.apache.coyote.http11.Http11Processor.service Error processing request
java.lang.NullPointerException
at org.apache.catalina.connector.Request.parseCookies(Request.java:3047)
at org.apache.catalina.connector.Request.getServerCookies(Request.java:2098)
at org.apache.catalina.connector.CoyoteAdapter.parseSessionCookiesId(CoyoteAdapter.java:1007)
at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:707)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
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)
17-Jan-2017 10:39:24.983 SEVERE [http-nio-8080-exec-7] org.apache.coyote.http11.Http11Processor.endRequest Error finishing response
java.lang.NullPointerException
第二个错误:
17-Jan-2017 11:08:33.696 SEVERE [http-nio-8080-exec-8] org.apache.coyote.http11.Http11Processor.endRequest Error finishing response
java.lang.NullPointerException
17-Jan-2017 11:08:33.743 SEVERE [http-nio-8080-exec-7] org.apache.coyote.http11.Http11Processor.service Error processing request
java.lang.NullPointerException
17-Jan-2017 11:08:33.743 SEVERE [http-nio-8080-exec-7] org.apache.coyote.http11.Http11Processor.endRequest Error finishing response
java.lang.NullPointerException
17-Jan-2017 11:08:33.838 SEVERE [http-nio-8080-exec-7] org.apache.coyote.http11.Http11Processor.service Error processing request
java.lang.NullPointerException
17-Jan-2017 11:08:33.838 SEVERE [http-nio-8080-exec-7] org.apache.coyote.http11.Http11Processor.endRequest Error finishing response
java.lang.NullPointerException
第三个错误:
17-Jan-2017 11:20:52.232 SEVERE [http-nio-8080-exec-3] org.apache.coyote.http11.Http11Processor.service Error processing request
java.lang.NullPointerException
at org.apache.tomcat.util.buf.MessageBytes.toChars(MessageBytes.java:257)
at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:641)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
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)
前端html总是打印错误:
Failed to load resource: the server responded with a status of 502 (Bad Gateway)
后端服务器主要使用Spring、Jersey,前端使用H5、AngularJS。任何想法,我将不胜感激!
【问题讨论】:
如果您使用com.sun.xml.bind.marshaller.NamespacePrefixMapper
并且它的getPreferredPrefix
返回一个空(或null)字符串,也可能发生这种情况。
【参考方案1】:
这是 8.5.x 以后的重构引入的 tomcat 的一个错误。可以搜索tomcat的bug列表https://bz.apache.org/bugzilla/show_bug.cgi?id=60918
可以通过升级tomcat版本解决问题,或者修改server.xml 设置 useSendfile="false"
<Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" maxHttpHeaderSize="16384" maxThreads="2000" connectionTimeout="60000" disableUploadTimeout="true" redirectPort="8443" useSendfile="false"/>
【讨论】:
【参考方案2】:我不是这方面的专家,但请求或 cookie 编码似乎存在某种问题。也可能是一个tomcat错误。
对于第一个错误,您可以尝试 Rfc6265CookieProcessor。详情请查看this。
<Context>
....
<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor" />
....
</Context>
【讨论】:
【参考方案3】:当您的 tomcat 版本出现问题时会发生这种类型的错误。如果没有测试用例来重现问题,Tomcat 开发人员几乎无能为力。看起来多个线程同时作用于同一个套接字。我无法判断这是故意的,是 Tomcat 错误的结果还是框架/应用程序正在做的事情。
我对此知之甚少,但我已经解决了我的问题after ready this.
其他解决方案:-
这也是asked before here。请问你用的是哪个版本的tomcat?
对于这个例外
SEVERE: An exception or error occurred in the container during the request processing
java.lang.NullPointerException
你需要read this stack overflow answer.
502 Bad Gateway 错误是一个 HTTP 状态代码,表示 Internet 上的一台服务器从另一台服务器收到无效响应。 为此,您需要read this tutorial.
【讨论】:
【参考方案4】:尝试将 http-nio-8080 替换为 http://localhost:8080 或 ip:8080
【讨论】:
以上是关于服务器:[http-nio-8080-exec-7] org.apache.coyote.http11.Http11Processor.service 处理请求时出错 java.lang.NullPo的主要内容,如果未能解决你的问题,请参考以下文章
struts2安全插件struts2-secure-jakarta-multipart-parser-plugin引起的文件上传问题