Announcement Announcement Module
Collapse
No announcement yet.
refering spring mvc and hibernate mapping in jsp Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • refering spring mvc and hibernate mapping in jsp

    i am working on a project it has three form beans Student, Parent and Academic i am using one to one relationship between Student-Parent and Student-Academic the code works fine with hibernate and it is creating 3 tables Student, Parent and Academic. I am trying to apply the same in spring mvc application using AbstractWizardController to add the details in the first page i am entering Student details which works fine but when i am refering to Parent attributes in the second page i am getting a error

    The StudentForm bean is like:
    public class StudentForm {
    String id;
    String firstName;
    String lastName;
    String dob;
    String phone;
    String sex;
    String address;
    Parent parent;
    Academic academic;
    ____getters and setters___
    }

    the second page in jsp is like:


    <core:bind path="studentForm.parent.fatherName">
    <core:message code="studentForm.parent.fatherName" />
    <input type="text" name="fatherName"
    value="${status.value}" />
    ${status.errorMessage}
    </core:bind>

    the error is:

    SEVERE: Invalid property 'parent' of bean class [beans.StudentForm]: Value of nested property 'parent' is null
    org.springframework.beans.NullValueInNestedPathExc eption: Invalid property 'parent' of bean class [beans.StudentForm]: Value of nested property 'parent' is null
    at org.springframework.beans.BeanWrapperImpl.getNeste dBeanWrapper(BeanWrapperImpl.java:449)
    at org.springframework.beans.BeanWrapperImpl.getBeanW rapperForPropertyPath(BeanWrapperImpl.java:424)
    at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:530)
    at org.springframework.validation.AbstractPropertyBin dingResult.getActualFieldValue(AbstractPropertyBin dingResult.java:79)
    at org.springframework.validation.AbstractBindingResu lt.getFieldValue(AbstractBindingResult.java:226)
    at org.springframework.web.servlet.support.BindStatus .<init>(BindStatus.java:120)
    at org.springframework.web.servlet.tags.BindTag.doSta rtTagInternal(BindTag.java:118)
    at org.springframework.web.servlet.tags.RequestContex tAwareTag.doStartTag(RequestContextAwareTag.java:7 7)
    at org.apache.jsp.WEB_002dINF.jsp.registration1_jsp._ jspService(registration1_jsp.java:104)
    at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:432)
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.pro cessRequest(ApplicationDispatcher.java:471)
    at org.apache.catalina.core.ApplicationDispatcher.doF orward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.for ward(ApplicationDispatcher.java:329)
    at org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi ew.java:236)
    at org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:257)
    at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1183)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:902)
    at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:807)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:511)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.p rocess(AbstractHttp11Processor.java:999)
    at org.apache.coyote.AbstractProtocol$AbstractConnect ionHandler.process(AbstractProtocol.java:565)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProce ssor.run(JIoEndpoint.java:309)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
    May 10, 2012 9:37:12 PM org.apache.catalina.core.ApplicationDispatcher invoke

  • #2
    Hi,

    i guess this happens due to, parent is null and you are trying to reference a property (fatherName) inside of it.

    Comment


    • #3
      hi

      Originally posted by amiladomingo View Post
      Hi,

      i guess this happens due to, parent is null and you are trying to reference a property (fatherName) inside of it.
      Yes that is what the error say but the problem is how do we refer to Parent bean elements from StudentForm bean while we are trying to apply one to one association mapping between StudentForm and Parent?

      Comment


      • #4
        I guess you'll have to initialize the parent. It can not be null.

        Comment

        Working...
        X