java.lang.ArrayIndexOutOfBoundsException

Spring JIRA | Johannes Nicolai | 6 years ago
  1. 0

    I created an enum "Timezone" using roo shell and added lots of constants (more than 600) to it. This enum is used as a property in one of my roo generated entities. Whenever I try to update/create/delete entities of this type with the scaffolded controller, the data base is updated correctly, but once the controller tries to redirect to a view, I get the following exception: java.lang.ArrayIndexOutOfBoundsException: 8192 at org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:715) at org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:622) at org.apache.coyote.http11.InternalOutputBuffer.sendHeader(InternalOutputBuffer.java:495) at org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1617) at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:952) at org.apache.coyote.Response.action(Response.java:183) at org.apache.coyote.Response.sendHeaders(Response.java:379) at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:305) at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:273) at org.apache.catalina.connector.Response.finishResponse(Response.java:493) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:322) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:409) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) 23.02.2011 10:53:12 org.apache.coyote.http11.Http11Processor process SCHWERWIEGEND: Error finishing response java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native Method) at org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:684) at org.apache.coyote.http11.InternalOutputBuffer.sendStatus(InternalOutputBuffer.java:419) at org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1604) at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:952) at org.apache.coyote.Response.action(Response.java:181) at org.apache.coyote.http11.InternalOutputBuffer.endRequest(InternalOutputBuffer.java:379) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:897) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:409) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) After this exception occurs, TomCat retries the operation which leads to a Hibernate exception in case of update (stale record), unique constraint exception in case of create and entity not found exception in case of delete. Debugging the application, the last break point that is hit before the index out of bound exception is the sendRedirect method in Spring's RedirectView class. Examining the targetUrl attribute in this method, I figured that all possible values of my enum type had been encoded as request parameters which forms a very long string which probably caused the index out of bound exception. Looking at the generated scaffolding code, all possible values of the enum property are added to the Model in a generated method called "populateTimezones" to present all possible selections in drop down boxes in the view. When doing the redirect after a create/update/delete operation, all model attributes are added to the targetUrl which leads to the array index out of bound exception. I worked around the problem by pushing some generated advices into my controller classes and add a model.addAttribute("timezones", null); before doing the redirect. I do not think that these attributes are ever needed after a redirect, so I suggest modifying the scaffolded code generator accordingly. Since this problem could not only happpen in case of huge enums but also in case of many candidates for relationships with other entities (so whenever a generated populate... method adds lots of entries to the model), I think this is not just an exotic problem. Another aspect of this problem seems to be the array index out of bound exception in TomCat. Even in case of ridiculously long target URLs, this should not cause exceptions like this which cause retries of operations with a side effect. I attached my enum class so that you can better reproduce the problem. Best, Johannes

    Spring JIRA | 6 years ago | Johannes Nicolai
    java.lang.ArrayIndexOutOfBoundsException
  2. 0

    I created an enum "Timezone" using roo shell and added lots of constants (more than 600) to it. This enum is used as a property in one of my roo generated entities. Whenever I try to update/create/delete entities of this type with the scaffolded controller, the data base is updated correctly, but once the controller tries to redirect to a view, I get the following exception: java.lang.ArrayIndexOutOfBoundsException: 8192 at org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:715) at org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:622) at org.apache.coyote.http11.InternalOutputBuffer.sendHeader(InternalOutputBuffer.java:495) at org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1617) at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:952) at org.apache.coyote.Response.action(Response.java:183) at org.apache.coyote.Response.sendHeaders(Response.java:379) at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:305) at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:273) at org.apache.catalina.connector.Response.finishResponse(Response.java:493) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:322) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:409) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) 23.02.2011 10:53:12 org.apache.coyote.http11.Http11Processor process SCHWERWIEGEND: Error finishing response java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native Method) at org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:684) at org.apache.coyote.http11.InternalOutputBuffer.sendStatus(InternalOutputBuffer.java:419) at org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1604) at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:952) at org.apache.coyote.Response.action(Response.java:181) at org.apache.coyote.http11.InternalOutputBuffer.endRequest(InternalOutputBuffer.java:379) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:897) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:409) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) After this exception occurs, TomCat retries the operation which leads to a Hibernate exception in case of update (stale record), unique constraint exception in case of create and entity not found exception in case of delete. Debugging the application, the last break point that is hit before the index out of bound exception is the sendRedirect method in Spring's RedirectView class. Examining the targetUrl attribute in this method, I figured that all possible values of my enum type had been encoded as request parameters which forms a very long string which probably caused the index out of bound exception. Looking at the generated scaffolding code, all possible values of the enum property are added to the Model in a generated method called "populateTimezones" to present all possible selections in drop down boxes in the view. When doing the redirect after a create/update/delete operation, all model attributes are added to the targetUrl which leads to the array index out of bound exception. I worked around the problem by pushing some generated advices into my controller classes and add a model.addAttribute("timezones", null); before doing the redirect. I do not think that these attributes are ever needed after a redirect, so I suggest modifying the scaffolded code generator accordingly. Since this problem could not only happpen in case of huge enums but also in case of many candidates for relationships with other entities (so whenever a generated populate... method adds lots of entries to the model), I think this is not just an exotic problem. Another aspect of this problem seems to be the array index out of bound exception in TomCat. Even in case of ridiculously long target URLs, this should not cause exceptions like this which cause retries of operations with a side effect. I attached my enum class so that you can better reproduce the problem. Best, Johannes

    Spring JIRA | 6 years ago | Johannes Nicolai
    java.lang.ArrayIndexOutOfBoundsException
  3. 0

    Tomcat - User - Tomcat 7 + exception while adding cookies

    nabble.com | 1 year ago
    java.lang.ArrayIndexOutOfBoundsException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Tomcat 7 + cookies (Tomcat forum at JavaRanch)

    coderanch.com | 1 year ago
    java.lang.ArrayIndexOutOfBoundsException
  6. 0

    Struts2 cookies (Struts forum at JavaRanch)

    coderanch.com | 1 year ago
    java.lang.ArrayIndexOutOfBoundsException

  1. Aria Pahlavan 49 times, last 1 week ago
  2. iridic 2 times, last 2 weeks ago
  3. danleyb2Interintel 1 times, last 5 months ago
  4. Stefan Braune 1 times, last 9 months ago
9 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.ArrayIndexOutOfBoundsException

    No message provided

    at java.lang.System.arraycopy()
  2. Java RT
    System.arraycopy
    1. java.lang.System.arraycopy(Native Method)
    1 frame
  3. Grizzly HTTP
    JIoEndpoint$SocketProcessor.run
    1. org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:684)
    2. org.apache.coyote.http11.InternalOutputBuffer.sendStatus(InternalOutputBuffer.java:419)
    3. org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1604)
    4. org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:952)
    5. org.apache.coyote.Response.action(Response.java:181)
    6. org.apache.coyote.http11.InternalOutputBuffer.endRequest(InternalOutputBuffer.java:379)
    7. org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:897)
    8. org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    9. org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:409)
    9 frames
  4. Java RT
    Thread.run
    1. java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    3. java.lang.Thread.run(Thread.java:662)
    3 frames