Reputation:
I am working on adding a new bean to a Business Object.
To do so, I first add the member to the PurchaseOrderDocument Class by assigning it the following:
protected String purchaseOrderCurrentCMActionStatus;
Then of course I assign it the usual getter and setters like so:
public String getPurchaseOrderCurrentCMActionStatus() {
return purchaseOrderCurrentCMActionStatus;
}
public void setPurchaseOrderCurrentCMActionStatus(String purchaseOrderCurrentCMActionStatus) {
this.purchaseOrderCurrentCMActionStatus = purchaseOrderCurrentCMActionStatus;
}
Okay, so that is all happening in my Java Class.
So now, in the corresponding XML file called PurchaseOrderDocument.xml located in the DataDictionary directory I added the following bean definition -
<bean id="PurchaseOrderDocument-purchaseOrderCurrentCMActionStatus"
parent="PurchaseOrderDocument-purchaseOrderCurrentCMActionStatus-parentBean"/>
<bean id="PurchaseOrderDocument-purchaseOrderCurrentCMActionStatus-parentBean" abstract="true" parent="AttributeDefinition">
<property name="name" value="purchaseOrderCurrentCMActionStatus"/>
<property name="label" value="Current CM Action Status"/>
<property name="required" value="false"/>
<property name="shortLabel" value="CM Status"/>
<property name="control">
<ref bean="HiddenControl"/>
</property>
</bean>
Next, I need to create the OJB mapping, so in the ojb.xml file I added the following line of XML code -
<field-descriptor name="purchaseOrderCurrentCMActionStatus" column="CURR_CM_ACTION_STATUS" jdbc-type="VARCHAR"/>
I also created the column CURR_CM_ACTION_STATUS in my corresponding TABLE - so I double and triple checked that the names were a spot on match.
Right -
So here's the question: Within my PurchaseOrderDocument I have a trigger that waits for an event that will fire off the "Setter" code I specified above for this bean. The weird thing is that this code that I have written is generating a NULL Pointer Exception.
I have pin-pointed the problem to the following line -
<bean id="PurchaseOrderDocument-purchaseOrderCurrentCMActionStatus-parentBean" abstract="true" parent="AttributeDefinition">
If I change the following line:
parent = "AttributeDefinition"
to
parent = "Note-noteText"
(Note is a Class and noteText is the member varaible the I ORIGINALLY had in this bean that I was inheriting from - but I don't want to inherit from the Note Class anymore, I want it local to my PurchaseOrderDocument class. Anyways, when I had the Note-noteText in there, I DID NOT get the null pointer exception, but rather, after the "set" method was called by my trigger, NOTHING was written to the database, which incidentally is ORACLE.)
Thus, this is my reason for moving away from inheritance and instead I want this bean to be local to THIS class.
A co-worker of mine mentioned that perhaps Spring is looking for this bean in the FORM and since I don't have it there - it is puking on it...but I have my doubts.
Also notice that I am using a HIDDEN CONTROL. When I added the parent="AttributeDefinition" text, I received an error saying that I didn't specify a control attribute. Since, this bean gets its contents NOT from USER input, I specified this HIDDEN CONTROL attribute.
Maybe this is part of the problem??
Here is the stack trace just in case -
Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:412) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085) org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241) org.kuali.rice.kns.web.struts.action.KualiRequestProcessor.process(KualiRequestProcessor.java:101) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.kuali.rice.kew.web.UserLoginFilter.doFilter(UserLoginFilter.java:92) org.jasig.cas.client.util.HttpServletRequestWrapperFilter.doFilter(HttpServletRequestWrapperFilter.java:50) org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:167) org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:121) org.kuali.rice.kns.web.filter.SetResponseBufferSizeFilter.doFilter(SetResponseBufferSizeFilter.java:78) org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125) org.kuali.rice.kns.web.filter.SessionFilter.doFilter(SessionFilter.java:41) root cause javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.NullPointerException org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:861) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794) org.apache.jsp.jsp.module.purap.PurchaseOrder_jsp._jspService(PurchaseOrder_jsp.java:269) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085) org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241) org.kuali.rice.kns.web.struts.action.KualiRequestProcessor.process(KualiRequestProcessor.java:101) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.kuali.rice.kew.web.UserLoginFilter.doFilter(UserLoginFilter.java:92) org.jasig.cas.client.util.HttpServletRequestWrapperFilter.doFilter(HttpServletRequestWrapperFilter.java:50) org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:167) org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:121) org.kuali.rice.kns.web.filter.SetResponseBufferSizeFilter.doFilter(SetResponseBufferSizeFilter.java:78) org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125) org.kuali.rice.kns.web.filter.SessionFilter.doFilter(SessionFilter.java:41) root cause java.lang.NullPointerException org.kuali.rice.kns.datadictionary.exporter.AttributesMapBuilder.buildAttributeMap(AttributesMapBuilder.java:66) org.kuali.rice.kns.datadictionary.exporter.AttributesMapBuilder.buildAttributesMap(AttributesMapBuilder.java:51) org.kuali.rice.kns.datadictionary.exporter.DocumentEntryMapper.mapEntry(DocumentEntryMapper.java:88) org.kuali.rice.kns.datadictionary.exporter.TransactionalDocumentEntryMapper.mapEntry(TransactionalDocumentEntryMapper.java:30) org.kuali.rice.kns.datadictionary.exporter.DataDictionaryMap.get(DataDictionaryMap.java:60) javax.el.MapELResolver.getValue(MapELResolver.java:51) javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54) org.apache.el.parser.AstValue.getValue(AstValue.java:123) org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:938) org.apache.jsp.tag.web.kr.documentPage_tag._jspx_meth_c_005fset_005f0(documentPage_tag.java:382) org.apache.jsp.tag.web.kr.documentPage_tag.doTag(documentPage_tag.java:313) org.apache.jsp.jsp.module.purap.PurchaseOrder_jsp._jspService(PurchaseOrder_jsp.java:260) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085) org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241) org.kuali.rice.kns.web.struts.action.KualiRequestProcessor.process(KualiRequestProcessor.java:101) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.kuali.rice.kew.web.UserLoginFilter.doFilter(UserLoginFilter.java:92) org.jasig.cas.client.util.HttpServletRequestWrapperFilter.doFilter(HttpServletRequestWrapperFilter.java:50) org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:167) org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:121) org.kuali.rice.kns.web.filter.SetResponseBufferSizeFilter.doFilter(SetResponseBufferSizeFilter.java:78) org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125) org.kuali.rice.kns.web.filter.SessionFilter.doFilter(SessionFilter.java:41)
Upvotes: 1
Views: 1032
Reputation:
The above code as it turns out was correct.
The problem with this was that I was calling my setter method on a Transient Object that wasn't being persisted by the Spring Framework. (e.g. I was calling it on an object whose scope ended in the block that I was calling it from!)
To fix this I simply called the setter on another instance of the same class that was in scope.
Ughh...
Live and learn.
Upvotes: 1