日期:2014-05-17  浏览次数:21440 次

servlet偶尔出现java.io.IOException
我在C#中调用servlet,这个servlet每天响应几千个请求,但只是4、5次报错,我现在连调试都没法做,唉
servlet的代码如下:
public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
Connection conn= null;
String cetifyResult =null;
StringBuilder requestData = new StringBuilder();
try {
BufferedReader reqIn = request.getReader();
String readline = null;
while((readline = reqIn.readLine())!=null ) 按照JAVA报错信息,83行指的就是这句 requestData.append(readline);



错误信息为:
java.io.IOException
at org.apache.jk.common.JkInputStream.receive(JkInputStream.java:205)
at org.apache.jk.common.JkInputStream.refillReadBuffer(JkInputStream.java:265)
at org.apache.jk.common.JkInputStream.doRead(JkInputStream.java:183)
at org.apache.coyote.Request.doRead(Request.java:428)
at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:304)
at org.apache.catalina.connector.InputBuffer.realReadChars(InputBuffer.java:360)
at org.apache.tomcat.util.buf.CharChunk.substract(CharChunk.java:412)
at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:408)
at org.apache.catalina.connector.CoyoteReader.read(CoyoteReader.java:105)
at org.apache.catalina.connector.CoyoteReader.readLine(CoyoteReader.java:154)
at org.ea.test.LicenseCertificationServlet.doPost(LicenseCertificationServlet.java:83)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
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:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:774)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:896)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Unknown Source)


------解决方案--------------------
参考这个
http://topic.csdn.net/t/20030816/03/2152573.html
getReader 方法只能调用一次,第二次调用就会抛IO异常,其次 servlet是线程不安全的,加入某一时刻同时调用了这个线程 可能导致线程问题,检查一下吧

------解决方案--------------------
探讨

参考这个
http://topic.csdn.net/t/20030816/03/2152573.html
getReader 方法只能调用一次,第二次调用就会抛IO异常,其次 servlet是线程不安全的,加入某一时刻同时调用了这个线程 可能导致线程问题,检查一下吧

------解决方案--------------------
Java code

servlet每天响应几千个请求,但只是4、5次报错