org.springframework.beans.NullValueInNestedPathException: Invalid property 'arrayTwo[0]' of bean class [com.test.TestForm]: Cannot access indexed value of property referenced in indexed property path 'arrayTwo[0]': returned null

Spring JIRA | Shishir K Singh | 1 decade ago
  1. 0

    Not sure if this is abug or I am doing something wrong: public class TestForm { private Boolean testBoolean; private String[] arrayOne; private String[] arrayTwo; public TestForm() {} public String[] getArrayOne() { return this.arrayOne; } public void setArrayOne(String[] arrayOne) { this.arrayOne = arrayOne; } public String[] getArrayTwo() { return this.arrayTwo; } public void setArrayTwo(String[] arrayTwo) { this.arrayTwo = arrayTwo; } public Boolean getTestBoolean() { return this.testBoolean; } public void setTestBoolean(Boolean testBoolean) { this.testBoolean = testBoolean; } } --------------------------------------------- And my test case is : --------------------------------------------- public void testBindWithInitializer() throws ServletException { ServletContext sc = new MockServletContext(); MockHttpServletRequest request = new MockHttpServletRequest(sc); request.addParameter("testBoolean", "true"); request.addParameter("arrayTwo", "arraytwo_1,arraytwo_2"); TestForm form = new TestForm(); Errors errors = BindUtils.bind(request,form, "form", new BindInitializer() { public void initBinder(ServletRequest request, ServletRequestDataBinder binder) { binder.registerCustomEditor(String[].class,"arrayTwo",new StringArrayPropertyEditor()); } }); assertTrue("arraytwo length", form.getArrayTwo().length == 2); } I get the following error : Testcase: testBindWithInitializer took 0.12 sec Caused an ERROR Invalid property 'arrayTwo[0]' of bean class [com.test.TestForm]: Cannot access indexed value of property referenced in indexed property path 'arrayTwo[0]': returned null org.springframework.beans.NullValueInNestedPathException: Invalid property 'arrayTwo[0]' of bean class [com.test.TestForm]: Cannot access indexed value of property referenced in indexed property path 'arrayTwo[0]': returned null at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:499) at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:484) at org.springframework.beans.BeanWrapperImpl.getPropertyType(BeanWrapperImpl.java:917) at org.springframework.validation.BindException.resolveMessageCodes(BindException.java:162) at org.springframework.validation.DataBinder.bind(DataBinder.java:229) at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:92) at org.springframework.web.bind.BindUtils.bind(BindUtils.java:65) at com.test.TestMail.testBindWithInitializer(TestMail.java:82) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22) at junit.extensions.TestSetup$1.protect(TestSetup.java:19) at junit.extensions.TestSetup.run(TestSetup.java:23) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:377) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:135)

    Spring JIRA | 1 decade ago | Shishir K Singh
    org.springframework.beans.NullValueInNestedPathException: Invalid property 'arrayTwo[0]' of bean class [com.test.TestForm]: Cannot access indexed value of property referenced in indexed property path 'arrayTwo[0]': returned null
  2. 0

    Not sure if this is abug or I am doing something wrong: public class TestForm { private Boolean testBoolean; private String[] arrayOne; private String[] arrayTwo; public TestForm() {} public String[] getArrayOne() { return this.arrayOne; } public void setArrayOne(String[] arrayOne) { this.arrayOne = arrayOne; } public String[] getArrayTwo() { return this.arrayTwo; } public void setArrayTwo(String[] arrayTwo) { this.arrayTwo = arrayTwo; } public Boolean getTestBoolean() { return this.testBoolean; } public void setTestBoolean(Boolean testBoolean) { this.testBoolean = testBoolean; } } --------------------------------------------- And my test case is : --------------------------------------------- public void testBindWithInitializer() throws ServletException { ServletContext sc = new MockServletContext(); MockHttpServletRequest request = new MockHttpServletRequest(sc); request.addParameter("testBoolean", "true"); request.addParameter("arrayTwo", "arraytwo_1,arraytwo_2"); TestForm form = new TestForm(); Errors errors = BindUtils.bind(request,form, "form", new BindInitializer() { public void initBinder(ServletRequest request, ServletRequestDataBinder binder) { binder.registerCustomEditor(String[].class,"arrayTwo",new StringArrayPropertyEditor()); } }); assertTrue("arraytwo length", form.getArrayTwo().length == 2); } I get the following error : Testcase: testBindWithInitializer took 0.12 sec Caused an ERROR Invalid property 'arrayTwo[0]' of bean class [com.test.TestForm]: Cannot access indexed value of property referenced in indexed property path 'arrayTwo[0]': returned null org.springframework.beans.NullValueInNestedPathException: Invalid property 'arrayTwo[0]' of bean class [com.test.TestForm]: Cannot access indexed value of property referenced in indexed property path 'arrayTwo[0]': returned null at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:499) at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:484) at org.springframework.beans.BeanWrapperImpl.getPropertyType(BeanWrapperImpl.java:917) at org.springframework.validation.BindException.resolveMessageCodes(BindException.java:162) at org.springframework.validation.DataBinder.bind(DataBinder.java:229) at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:92) at org.springframework.web.bind.BindUtils.bind(BindUtils.java:65) at com.test.TestMail.testBindWithInitializer(TestMail.java:82) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22) at junit.extensions.TestSetup$1.protect(TestSetup.java:19) at junit.extensions.TestSetup.run(TestSetup.java:23) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:377) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:135)

    Spring JIRA | 1 decade ago | Shishir K Singh
    org.springframework.beans.NullValueInNestedPathException: Invalid property 'arrayTwo[0]' of bean class [com.test.TestForm]: Cannot access indexed value of property referenced in indexed property path 'arrayTwo[0]': returned null
  3. 0

    {code:java} org.springframework.beans.InvalidPropertyException: Invalid property 'applicationInfoList[0]' of bean class [org.test.model.ApplicationForm]: Illegal attempt to get property 'applicationInfoList' threw exception; nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'applicationInfoList[0]' of bean class [org.test.model.ApplicationForm]: Cannot access indexed value of property referenced in indexed property path 'applicationInfoList[0]': returned null at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:826) at org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:555) at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:532) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:904) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76) at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:673) at org.springframework.validation.DataBinder.doBind(DataBinder.java:569) at org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:191) at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:110) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.doBind(AnnotationMethodHandlerAdapter.java:734) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doBind(HandlerMethodInvoker.java:815) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:359) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3594) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) Caused by: org.springframework.beans.NullValueInNestedPathException: Invalid property 'applicationInfoList[0]' of bean class [org.test.model.ApplicationForm]: Cannot access indexed value of property referenced in indexed property path 'applicationInfoList[0]': returned null at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:744) ... 32 more {code}

    Spring JIRA | 5 years ago | Parthiban Samykutti
    org.springframework.beans.InvalidPropertyException: Invalid property 'applicationInfoList[0]' of bean class [org.test.model.ApplicationForm]: Illegal attempt to get property 'applicationInfoList' threw exception; nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'applicationInfoList[0]' of bean class [org.test.model.ApplicationForm]: Cannot access indexed value of property referenced in indexed property path 'applicationInfoList[0]': returned null
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    {code:java} org.springframework.beans.InvalidPropertyException: Invalid property 'applicationInfoList[0]' of bean class [org.test.model.ApplicationForm]: Illegal attempt to get property 'applicationInfoList' threw exception; nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'applicationInfoList[0]' of bean class [org.test.model.ApplicationForm]: Cannot access indexed value of property referenced in indexed property path 'applicationInfoList[0]': returned null at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:826) at org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:555) at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:532) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:904) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76) at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:673) at org.springframework.validation.DataBinder.doBind(DataBinder.java:569) at org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:191) at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:110) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.doBind(AnnotationMethodHandlerAdapter.java:734) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doBind(HandlerMethodInvoker.java:815) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:359) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3594) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) Caused by: org.springframework.beans.NullValueInNestedPathException: Invalid property 'applicationInfoList[0]' of bean class [org.test.model.ApplicationForm]: Cannot access indexed value of property referenced in indexed property path 'applicationInfoList[0]': returned null at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:744) ... 32 more {code}

    Spring JIRA | 5 years ago | Parthiban Samykutti
    org.springframework.beans.InvalidPropertyException: Invalid property 'applicationInfoList[0]' of bean class [org.test.model.ApplicationForm]: Illegal attempt to get property 'applicationInfoList' threw exception; nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'applicationInfoList[0]' of bean class [org.test.model.ApplicationForm]: Cannot access indexed value of property referenced in indexed property path 'applicationInfoList[0]': returned null
  6. 0

    Spring MVC/Hibernate - NullValueInNestedPathException, Invalid property, value of nested property is null?

    Stack Overflow | 3 years ago | Joshua
    org.springframework.beans.NullValueInNestedPathException: Invalid property 'empCalList[0].shiftAssignmentVO' of bean class [com.safeway.dtr.employee.vo.EmpCalManager]: Value of nested property 'empCalList[0].shiftAssignmentVO' is null

    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. org.springframework.beans.NullValueInNestedPathException

      Invalid property 'arrayTwo[0]' of bean class [com.test.TestForm]: Cannot access indexed value of property referenced in indexed property path 'arrayTwo[0]': returned null

      at org.springframework.beans.BeanWrapperImpl.getPropertyValue()
    2. Spring Beans
      BeanWrapperImpl.getPropertyType
      1. org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:499)
      2. org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:484)
      3. org.springframework.beans.BeanWrapperImpl.getPropertyType(BeanWrapperImpl.java:917)
      3 frames
    3. Spring Context
      DataBinder.bind
      1. org.springframework.validation.BindException.resolveMessageCodes(BindException.java:162)
      2. org.springframework.validation.DataBinder.bind(DataBinder.java:229)
      2 frames
    4. Spring
      BindUtils.bind
      1. org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:92)
      2. org.springframework.web.bind.BindUtils.bind(BindUtils.java:65)
      2 frames
    5. com.test
      TestMail.testBindWithInitializer
      1. com.test.TestMail.testBindWithInitializer(TestMail.java:82)
      1 frame
    6. Java RT
      DelegatingMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      3 frames
    7. JUnit
      TestSetup.run
      1. junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
      2. junit.extensions.TestSetup$1.protect(TestSetup.java:19)
      3. junit.extensions.TestSetup.run(TestSetup.java:23)
      3 frames
    8. org.eclipse.ant
      InternalAntRunner.main
      1. org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:377)
      2. org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:135)
      2 frames