java - Spring form not populating the data to model object -
my model object has 'ctlgentry' attribute has attribute 'yearpublished'. form has populated following error thrown:
org.hibernate.propertyaccessexception: null value assigned property of primitive type setter of com.csu.library.mvc.dto.catalogueentry.yearpublished] root cause java.lang.illegalargumentexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.hibernate.property.basicpropertyaccessor$basicsetter.set(basicpropertyaccessor.java:65) @ org.hibernate.tuple.entity.abstractentitytuplizer.setpropertyvalues(abstractentitytuplizer.java:707) @ org.hibernate.tuple.entity.pojoentitytuplizer.setpropertyvalues(pojoentitytuplizer.java:371) @ org.hibernate.persister.entity.abstractentitypersister.setpropertyvalues(abstractentitypersister.java:4463) @ org.hibernate.event.internal.abstractsaveeventlistener.performsaveorreplicate(abstractsaveeventlistener.java:276) @ org.hibernate.event.internal.abstractsaveeventlistener.performsave(abstractsaveeventlistener.java:193) @ org.hibernate.event.internal.abstractsaveeventlistener.savewithgeneratedid(abstractsaveeventlistener.java:126) @ org.hibernate.event.internal.defaultsaveorupdateeventlistener.savewithgeneratedorrequestedid(defaultsaveorupdateeventlistener.java:204) @ org.hibernate.event.internal.defaultsaveeventlistener.savewithgeneratedorrequestedid(defaultsaveeventlistener.java:55) @ org.hibernate.event.internal.defaultsaveorupdateeventlistener.entityistransient(defaultsaveorupdateeventlistener.java:189) @ org.hibernate.event.internal.defaultsaveeventlistener.performsaveorupdate(defaultsaveeventlistener.java:49) @ org.hibernate.event.internal.defaultsaveorupdateeventlistener.onsaveorupdate(defaultsaveorupdateeventlistener.java:90) @ org.hibernate.internal.sessionimpl.firesave(sessionimpl.java:756) @ org.hibernate.internal.sessionimpl.save(sessionimpl.java:748) @ org.hibernate.internal.sessionimpl.save(sessionimpl.java:744) @ com.csu.library.mvc.dao.generic.generichibernatedao.save(generichibernatedao.java:73) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:317) @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:183) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:150) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:110) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:204) @ com.sun.proxy.$proxy54.save(unknown source) @ com.csu.library.mvc.service.impl.catalogueentryserviceimpl.additem(catalogueentryserviceimpl.java:22) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:317) @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:183) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:150) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:110) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:204) @ com.sun.proxy.$proxy55.additem(unknown source) @ com.csu.library.mvc.controller.catalogueentrycontroller.addcatalogueentry(catalogueentrycontroller.java:42) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.springframework.web.method.support.invocablehandlermethod.invoke(invocablehandlermethod.java:219) @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:132) @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:104) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:745) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:686) @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:80) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:925) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:856) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:920) @ org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:827) @ javax.servlet.http.httpservlet.service(httpservlet.java:647) @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:801) @ javax.servlet.http.httpservlet.service(httpservlet.java:728) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:222) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:123) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:472) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:171) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:947) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:408) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1009) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:312) @ java.util.concurrent.threadpoolexecutor$worker.runtask(threadpoolexecutor.java:895) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:918) @ java.lang.thread.run(thread.java:680)
other data loaded onto object yearpublished throws error. following code jsp form populates catalogueentry item:
<form:form method="post" action="addcatalogueentry" commandname="catalogueentry"> <table> <tr> <td><form:label path="title">title of book:</form:label></td> <td><form:input path="title"/></td> </tr> <tr> <td><form:label path="yearpublished">year published:</form:label></td> <td><form:input path="yearpublished"/></td> </tr> <tr> <td><form:label path="isbn">isbn number:</form:label></td> <td><form:input path="isbn"/></td> </tr> <tr> <td><form:label path="publisher">publisher:</form:label></td> <td><form:input path="publisher"/></td> </tr> <tr> <td><form:label path="countryofpublication">country of publication</form:label></td> <td><form:input path="countryofpublication"/></td> </tr> <tr> <td><form:label path="authors">authors</form:label></td> <td><form:input path="authors"/></td> </tr> <!--<c:foreach items="$catalogueentry.authorlist" var="author" varstatus="status"> <tr> <td>first name</td> <td><input name="authorlist[${status.index}].firstname" id="authorlist[${status.index}].firstname"/></td> <%-- <td><form:input path="personlist[${i.index}].name" id="name${i.index}" /></td> <td><form:input path="personlist[${i.index}].age" id="age${i.index}" /></td> --%> </tr> <tr> <td>last name</td> <td><input name="authorlist[${status.index}].lastname" id="authorlist[${status.index}].lastname"/></td> </tr> </c:foreach> --> <tr> <td><input type="submit" value="clear" /></td> <td><input type="submit" value="submit" /></td> </tr> </table> </form:form>
the getters , setters field is:
private integer yearpublished; @column(name="year_published") @notnull public integer getyearpublished() { return yearpublished; } public void setyearpublished(int yearpublished) { this.yearpublished = yearpublished; }
use non-primitive wrapper types (eg. integer
int
, float
float
).
Comments
Post a Comment