java.lang.IndexOutOfBoundsException

Spring JIRA | Stephane Broussin | 8 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    The ResourceServlet uses the "in.available()" syntax which seems to fail when running IBM WebSphere 6's JRE. This happens both with compressed (gzipped) content or not. By replacing the code with a more traditionnal approach (using in.read() like "FileCopyUtils" does), it works fine ! My proposition of fix is: ----------------------------------- replace in 'doGet' method: while (in.available() > 0) { int len = in.read(buffer); out.write(buffer, 0, len); } ----------------------------------- by: int bytesRead = -1; while ((bytesRead = in.read(buffer)) != -1) { out.write(buffer, 0, bytesRead); } By the way, the exception is: [10/20/08 13:49:59:905 CEST] 0000002a SystemOut O 20/10/2008 13:49:59,905 DEBUG [WebContainer : 0] com.fortis.rsa.spring.webflow.js.ResourceServlet - Enabling GZIP compression for the current response. [10/20/08 13:49:59:905 CEST] 0000002a SystemErr R java.lang.IndexOutOfBoundsException at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:128) at java.util.zip.GZIPOutputStream.write(GZIPOutputStream.java:93) at com.fortis.rsa.spring.webflow.js.ResourceServlet$GZIPResponseStream.write(ResourceServlet.java:352) at com.fortis.rsa.spring.webflow.js.ResourceServlet.doGet(ResourceServlet.java:127) at javax.servlet.http.HttpServlet.service(HttpServlet.java:751) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1572) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1521) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:113) at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:82) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:759) at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3174) at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:253) at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:229) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1970) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:114)

    Spring JIRA | 8 years ago | Stephane Broussin
    java.lang.IndexOutOfBoundsException
  2. 0

    The ResourceServlet uses the "in.available()" syntax which seems to fail when running IBM WebSphere 6's JRE. This happens both with compressed (gzipped) content or not. By replacing the code with a more traditionnal approach (using in.read() like "FileCopyUtils" does), it works fine ! My proposition of fix is: ----------------------------------- replace in 'doGet' method: while (in.available() > 0) { int len = in.read(buffer); out.write(buffer, 0, len); } ----------------------------------- by: int bytesRead = -1; while ((bytesRead = in.read(buffer)) != -1) { out.write(buffer, 0, bytesRead); } By the way, the exception is: [10/20/08 13:49:59:905 CEST] 0000002a SystemOut O 20/10/2008 13:49:59,905 DEBUG [WebContainer : 0] com.fortis.rsa.spring.webflow.js.ResourceServlet - Enabling GZIP compression for the current response. [10/20/08 13:49:59:905 CEST] 0000002a SystemErr R java.lang.IndexOutOfBoundsException at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:128) at java.util.zip.GZIPOutputStream.write(GZIPOutputStream.java:93) at com.fortis.rsa.spring.webflow.js.ResourceServlet$GZIPResponseStream.write(ResourceServlet.java:352) at com.fortis.rsa.spring.webflow.js.ResourceServlet.doGet(ResourceServlet.java:127) at javax.servlet.http.HttpServlet.service(HttpServlet.java:751) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1572) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1521) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:113) at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:82) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:759) at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3174) at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:253) at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:229) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1970) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:114)

    Spring JIRA | 8 years ago | Stephane Broussin
    java.lang.IndexOutOfBoundsException

    Root Cause Analysis

    1. java.lang.IndexOutOfBoundsException

      No message provided

      at java.util.zip.DeflaterOutputStream.write()
    2. Java RT
      GZIPOutputStream.write
      1. java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:128)
      2. java.util.zip.GZIPOutputStream.write(GZIPOutputStream.java:93)
      2 frames
    3. com.fortis.rsa
      ResourceServlet.doGet
      1. com.fortis.rsa.spring.webflow.js.ResourceServlet$GZIPResponseStream.write(ResourceServlet.java:352)
      2. com.fortis.rsa.spring.webflow.js.ResourceServlet.doGet(ResourceServlet.java:127)
      2 frames
    4. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:751)
      2. javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      2 frames
    5. WebSphere
      WebContainer.handleRequest
      1. com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1572)
      2. com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1521)
      3. com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:113)
      4. com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:82)
      5. com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:759)
      6. com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3174)
      7. com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:253)
      8. com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:229)
      9. com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1970)
      9 frames
    6. com.ibm.ws
      WCChannelLink.ready
      1. com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:114)
      1 frame