java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

Spring JIRA | Amit Baghel | 2 months ago
  1. 0

    I am using Spring Boot 1.4.0.RELEASE and following is method in Controller. {code:java} @RequestMapping(value = "/postComment", method = RequestMethod.POST) public @ResponseBody String postComment(GenericComments<Comment> comment) { System.out.println(comment.getCommentList()); return "success"; } {code} GenericComments class is like below. {code:java} public class GenericComments<T> { private List<T> commentList; public List<T> getCommentList() { return commentList; } public void setCommentList(List<T> commentList) { this.commentList = commentList; } {code} Comment class is like below. {code:java} public class Comment { private Long id; private String message; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } } {code} I am calling the Controller method from jsp like below. {code:java} <html> <body> <form method="post" name="comment" action="/postComment"> <input type="text" id="commentList[0].message" name="commentList[0].message" /></td> <input type="submit"/> </form> </body> </html> {code} When I click submit button I get below exception. {code:java} Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'commentList[0]' of bean class [com.my.app.GenericComments]: Index of out of bounds in property path 'commentList[0]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0] with root cause java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[na:1.8.0_45] at java.util.ArrayList.get(ArrayList.java:429) ~[na:1.8.0_45] at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:652) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.AbstractNestablePropertyAccessor.getNestedPropertyAccessor(AbstractNestablePropertyAccessor.java:836) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyAccessorForPropertyPath(AbstractNestablePropertyAccessor.java:813) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:270) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:834) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.validation.DataBinder.doBind(DataBinder.java:730) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:192) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:106) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.bindRequestParameters(ServletModelAttributeMethodProcessor.java:150) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:114) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) ~[tomcat-embed-core-8.5.4.jar:8.5.4] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) ~[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.4.jar:8.5.4] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.4.jar:8.5.4] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45] {code}

    Spring JIRA | 2 months ago | Amit Baghel
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  2. 0

    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 Error

    GitHub | 1 year ago | beemi
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  3. 0

    IndexOutOfBoundsException when running out of numbers

    GitHub | 2 years ago | baeda
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    IndexOutOfBoundsException at SQLMergeClause.execute()

    GitHub | 2 years ago | cowwoc
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  6. 0

    Pump: IndexOutOfBoundsException: Index: 0, Size: 0

    GitHub | 2 years ago | jandam
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

  1. Shadd518 5 times, last 4 months ago
  2. filpgame 1 times, last 2 weeks ago
  3. Aria Pahlavan 6 times, last 2 weeks ago
  4. bmacedo 4 times, last 2 weeks ago
  5. MoYapro 5 times, last 2 weeks ago
63 more registered users
31 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.IndexOutOfBoundsException

    Index: 0, Size: 0

    at java.util.ArrayList.rangeCheck()
  2. Java RT
    ArrayList.get
    1. java.util.ArrayList.rangeCheck(ArrayList.java:653)[na:1.8.0_45]
    2. java.util.ArrayList.get(ArrayList.java:429)[na:1.8.0_45]
    2 frames
  3. Spring Beans
    AbstractPropertyAccessor.setPropertyValues
    1. org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:652)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    2. org.springframework.beans.AbstractNestablePropertyAccessor.getNestedPropertyAccessor(AbstractNestablePropertyAccessor.java:836)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    3. org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyAccessorForPropertyPath(AbstractNestablePropertyAccessor.java:813)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    4. org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:270)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    5. org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    5 frames
  4. Spring Context
    DataBinder.doBind
    1. org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:834)[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    2. org.springframework.validation.DataBinder.doBind(DataBinder.java:730)[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    2 frames
  5. Spring
    ServletRequestDataBinder.bind
    1. org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:192)[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    2. org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:106)[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    2 frames
  6. Spring MVC
    ServletModelAttributeMethodProcessor.bindRequestParameters
    1. org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.bindRequestParameters(ServletModelAttributeMethodProcessor.java:150)[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    1 frame
  7. Spring
    InvocableHandlerMethod.invokeForRequest
    1. org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:114)[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    2. org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    3. org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161)[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    4. org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128)[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    4 frames
  8. Spring MVC
    FrameworkServlet.doPost
    1. org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    2. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    3. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    4. org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    5. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    6. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    7. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    8. org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    8 frames
  9. JavaServlet
    HttpServlet.service
    1. javax.servlet.http.HttpServlet.service(HttpServlet.java:648)[tomcat-embed-core-8.5.4.jar:8.5.4]
    1 frame
  10. Spring MVC
    FrameworkServlet.service
    1. org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    1 frame
  11. JavaServlet
    HttpServlet.service
    1. javax.servlet.http.HttpServlet.service(HttpServlet.java:729)[tomcat-embed-core-8.5.4.jar:8.5.4]
    1 frame
  12. Glassfish Core
    ApplicationFilterChain.doFilter
    1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)[tomcat-embed-core-8.5.4.jar:8.5.4]
    2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)[tomcat-embed-core-8.5.4.jar:8.5.4]
    2 frames
  13. Tomcat WS
    WsFilter.doFilter
    1. org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)[tomcat-embed-websocket-8.5.4.jar:8.5.4]
    1 frame
  14. Glassfish Core
    ApplicationFilterChain.doFilter
    1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)[tomcat-embed-core-8.5.4.jar:8.5.4]
    2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)[tomcat-embed-core-8.5.4.jar:8.5.4]
    2 frames
  15. Spring
    OncePerRequestFilter.doFilter
    1. org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    2. org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    2 frames
  16. Glassfish Core
    CoyoteAdapter.service
    1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)[tomcat-embed-core-8.5.4.jar:8.5.4]
    2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)[tomcat-embed-core-8.5.4.jar:8.5.4]
    3. org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)[tomcat-embed-core-8.5.4.jar:8.5.4]
    4. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)[tomcat-embed-core-8.5.4.jar:8.5.4]
    5. org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)[tomcat-embed-core-8.5.4.jar:8.5.4]
    6. org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)[tomcat-embed-core-8.5.4.jar:8.5.4]
    7. org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)[tomcat-embed-core-8.5.4.jar:8.5.4]
    8. org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)[tomcat-embed-core-8.5.4.jar:8.5.4]
    9. org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)[tomcat-embed-core-8.5.4.jar:8.5.4]
    9 frames
  17. Grizzly HTTP
    SocketProcessorBase.run
    1. org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)[tomcat-embed-core-8.5.4.jar:8.5.4]
    2. org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)[tomcat-embed-core-8.5.4.jar:8.5.4]
    3. org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)[tomcat-embed-core-8.5.4.jar:8.5.4]
    4. org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)[tomcat-embed-core-8.5.4.jar:8.5.4]
    5. org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)[tomcat-embed-core-8.5.4.jar:8.5.4]
    5 frames
  18. Java RT
    ThreadPoolExecutor$Worker.run
    1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[na:1.8.0_45]
    2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[na:1.8.0_45]
    2 frames
  19. Tomcat Util
    TaskThread$WrappingRunnable.run
    1. org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)[tomcat-embed-core-8.5.4.jar:8.5.4]
    1 frame
  20. Java RT
    Thread.run
    1. java.lang.Thread.run(Thread.java:745)[na:1.8.0_45]
    1 frame