Perhaps change your code from
while((bytesRead = in.read(buf)) > 0) {

while((bytesRead = in.read(buf)) != -1) {

>From api:
Reads the next byte of data from the input stream. The value byte is
returned as an int in the range 0 to 255. If no byte is available
because the end of the stream has been reached, the value -1 is
returned. This method blocks until input data is available, the end of
the stream is detected, or an exception is thrown.

HTH.

On Tue, Nov 24, 2009 at 10:57 AM,  <geoff...@fileflow.com> wrote:
> Hi everyone.
> I'm stuck with a problem I don't understand. We have a tomcat server and
> after redeploying our war file, we get this error:
> java.lang.ArrayIndexOutOfBoundsException
> at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:346)
> at
> org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:764)
> at
> org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:118)
> at
> org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:573)
> at org.apache.coyote.Response.doWrite(Response.java:560)
> at
> org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:353)
> at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:325)
> at
> org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:381)
> at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:370)
> at
> org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)
> at com.fileflow.downloader.Downloader.doGet(Downloader.java:123)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
> 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:128)
> 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:293)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
> at java.lang.Thread.run(Thread.java:619)
> Notice that there are no number on the first line and it is usually the
> case.
> The code that is "responsible is:
> private ServletOutputStream out;
> private InputStream in;
> ...
> in = new FileInputStream(tmp);
> ...
> out = response.getOutputStream();
> byte[] buf = new byte[8 * 1024]; // 8K buffer
> int bytesRead;
> while((bytesRead = in.read(buf)) > 0) {
> out.write(buf, 0, bytesRead);
> }
> The updated code didn't change anything in that Servlet so I really have no
> clue what happened. It happens on tomcat 6.0.18 and 6.0.20. Java is
> 1.6.0_11.
> Thanks for any help.
>
> Best Regards
> Geoffrey
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to