views:

202

answers:

1

I have a problem that causes all threads in JBOSS to block while reading the input stream. It does not happen predictably and the system can run for days (or longer) before it starts to suffer. The problem looks similar to question 1624159 but I have yet to try setting -Dhttp.keepAlive=false as recommended in the answer because I wondered if anyone else has a different/better solution. I would rather not have to incur a performance hit by setting this property to false (assuming that even fixes the problem). There are some Sun bugs that talk about issues with BufferedReaders and InputStream reading (bug 6192696, bug 6409506), but to me they seem a bit inconclusive. Your thoughts/advice/experience with an issue like this and the Sun bugs would be welcome.

Here is the exception:

java.io.IOException
at org.apache.jk.common.JkInputStream.receive(JkInputStream.java:190)
at org.apache.jk.common.JkInputStream.refillReadBuffer(JkInputStream.java:249)
at org.apache.jk.common.JkInputStream.doRead(JkInputStream.java:168)
at org.apache.coyote.Request.doRead(Request.java:418)
at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:284)
at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:404)
at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:299)
at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:192)
at com.vicinity.ExtractMessageServlet.service(ExtractMessageServlet.java:62)
<SNIP>

Here is a sample of the request headers:

POST http: //www.xyz.com HTTP/1.0
Host: www.xyz.com:80
Accept: */*
Content-Type: application/octet-stream
Content-Length: 00597
Session-Key: 812a0000

Here is the Servlet code of the web application. It get's stuck on servletInputStream.read:

int lengthOfBuffer = request.getContentLength();
byte[] buffer = new byte[lengthOfBuffer];
ByteArrayOutputStream output = new ByteArrayOutputStream(lengthOfBuffer);
ServletInputStream servletInputStream = request.getInputStream();
int readBytes = -1;
while ((readBytes = servletInputStream.read(buffer, 0, lengthOfBuffer)) != -1) {
    output.write(buffer, 0, readBytes);
}
byte[] inputStream = output.toByteArray();
...
// Continue to process the input stream

(JBoss version is JBoss AS 4.0.5.GA. Also mod_jk is routing http requests on port 80 from Apache server to the JBoss server - if that's of interest).

A: 

JkInputStream.receive will throw a message-less IOException if something went wrong when reading from the underlying TCP socket, unfortunately without specifying what went wrong. You may find more details on the problem cause if you enable all log levels for the org.apache package and check what is logged just before the exception is thrown.

jarnbjo