我想更好地了解Tomcat如何处理请求以及为什么我的具体问题可能会发生.
我试图用Netflix Hystrix框架增强我现有的Spring MVC Web应用程序.这涉及添加一个特定于hystrix的servlet来处理以/hystrix.stream结尾的请求.
根据日志(如下所示),此映射有效,请求将转发到正确的servlet.但是,抛出的异常不会在servlet中发生.我也尝试扩展servlet以添加额外的日志记录 - 但似乎servlet中没有方法被调用.似乎发生了异常,因为Tomcat上的一些内部工作我不知道.
这是我的web.xml的一个片段(注意我的应用程序的其余部分工作正常 - 这只是关于/hystrix.stream的请求):
HystrixMetricsStreamServlet HystrixMetricsStreamServlet com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet HystrixMetricsStreamServlet /hystrix.stream
当我导航到loalhost:8080/web-app/hystrix.stream时,我被转发到Tomcat 404错误.tomcat的日志文件中出现以下异常:
2014-04-16 15:53:22 DEBUG AuthenticatorBase:419 - Security checking request GET /web-app/hystrix.stream 2014-04-16 15:53:22 DEBUG WebappClassLoader:1582 - loadClass(com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet, false) 2014-04-16 15:53:22 DEBUG WebappClassLoader:1598 - Returning class from cache 2014-04-16 15:53:22 DEBUG RealmBase:617 - No applicable constraints defined 2014-04-16 15:53:22 DEBUG AuthenticatorBase:501 - Not subject to any constraint 2014-04-16 15:53:22 DEBUG [localhost]:449 - Processing ErrorPage[errorCode=404, location=/404.htm] 2014-04-16 15:53:22 DEBUG Http11Processor:986 - Error parsing HTTP request header java.io.EOFException: Unexpected EOF read on the socket at org.apache.coyote.http11.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:99) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:952) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 2014-04-16 15:53:22 DEBUG Http11Protocol:645 - Socket: [org.apache.tomcat.util.net.SocketWrapper@56a7cbf2:129bf96a[TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: Socket[addr=/0:0:0:0:0:0:0:1,port=53783,localport=8443]]], Status in: [OPEN_READ], State out: [CLOSED] 2014-04-16 15:53:22 DEBUG LimitLatch:126 - Counting down[http-bio-8443-exec-1] latch=4 2014-04-16 15:53:22 DEBUG Http11Processor:986 - Error parsing HTTP request header java.io.EOFException: Unexpected EOF read on the socket at org.apache.coyote.http11.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:99) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:952) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
有没有人遇到过这样的事情?正如我所提到的,我的应用程序运行正常 - 这只适用于/hystrix.stream.我已经使用Chrome Postman插件将Accept和Content-Type = application/json标头添加到请求中 - 两者都没有成功.据我所知,对此servlet的请求没有任何标头要求
谢谢您的帮助.