Announcement Announcement Module
No announcement yet.
refering spring mvc and hibernate mapping in jsp Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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}" />

    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(
    at org.springframework.beans.BeanWrapperImpl.getBeanW rapperForPropertyPath(
    at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(
    at org.springframework.validation.AbstractPropertyBin dingResult.getActualFieldValue(AbstractPropertyBin
    at org.springframework.validation.AbstractBindingResu lt.getFieldValue(
    at .<init>(
    at org.springframework.web.servlet.tags.BindTag.doSta rtTagInternal(
    at org.springframework.web.servlet.tags.RequestContex tAwareTag.doStartTag( 7)
    at org.apache.jsp.WEB_002dINF.jsp.registration1_jsp._ jspService(
    at org.apache.jasper.runtime.HttpJspBase.service(Http
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    at org.apache.jasper.servlet.JspServletWrapper.servic e(
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(
    at org.apache.jasper.servlet.JspServlet.service(JspSe
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    at ternalDoFilter(
    at Filter(
    at org.apache.catalina.core.ApplicationDispatcher.inv oke(
    at cessRequest(
    at org.apache.catalina.core.ApplicationDispatcher.doF orward(
    at org.apache.catalina.core.ApplicationDispatcher.for ward(
    at org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi
    at org.springframework.web.servlet.view.AbstractView. render(
    at org.springframework.web.servlet.DispatcherServlet. render(
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(
    at org.springframework.web.servlet.DispatcherServlet. doService(
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(
    at org.springframework.web.servlet.FrameworkServlet.d oPost(
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    at ternalDoFilter(
    at Filter(
    at org.apache.catalina.core.StandardWrapperValve.invo ke(
    at org.apache.catalina.core.StandardContextValve.invo ke(
    at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(
    at org.apache.catalina.core.StandardHostValve.invoke(
    at org.apache.catalina.valves.ErrorReportValve.invoke (
    at org.apache.catalina.valves.AccessLogValve.invoke(A
    at org.apache.catalina.core.StandardEngineValve.invok e(
    at org.apache.catalina.connector.CoyoteAdapter.servic e(
    at org.apache.coyote.http11.AbstractHttp11Processor.p rocess(
    at org.apache.coyote.AbstractProtocol$AbstractConnect ionHandler.process(
    at java.util.concurrent.ThreadPoolExecutor$ Task(
    at java.util.concurrent.ThreadPoolExecutor$ (
    May 10, 2012 9:37:12 PM org.apache.catalina.core.ApplicationDispatcher invoke

  • #2

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


    • #3

      Originally posted by amiladomingo View Post

      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?


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