我正在努力向业务对象添加新bean。
为此,我首先通过为其分配以下内容将成员添加到PurchaseOrderDocument类:
protected String purchaseOrderCurrentCMActionStatus;
然后我当然会给它分配通常的getter和setter,如下所示:
public String getPurchaseOrderCurrentCMActionStatus() {
return purchaseOrderCurrentCMActionStatus;
}
public void setPurchaseOrderCurrentCMActionStatus(String purchaseOrderCurrentCMActionStatus) {
this.purchaseOrderCurrentCMActionStatus = purchaseOrderCurrentCMActionStatus;
}
好的,所以这一切都发生在我的Java类中。
现在,在位于DataDictionary目录中的名为PurchaseOrderDocument.xml的相应XML文件中,我添加了以下bean定义 -
<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>
接下来,我需要创建OJB映射,因此在ojb.xml文件中我添加了以下XML代码行 -
<field-descriptor name="purchaseOrderCurrentCMActionStatus" column="CURR_CM_ACTION_STATUS" jdbc-type="VARCHAR"/>
我还在相应的TABLE中创建了CURR_CM_ACTION_STATUS列 - 所以我进行了双倍和三倍检查,这些名称是匹配的一个点。
对 -
所以这是问题所在: 在我的PurchaseOrderDocument中,我有一个触发器,它等待一个事件,该事件将触发我为此bean指定的“Setter”代码。 奇怪的是,我编写的这段代码正在生成一个NULL指针异常。
我已将问题指向以下行 -
<bean id="PurchaseOrderDocument-purchaseOrderCurrentCMActionStatus-parentBean" abstract="true" parent="AttributeDefinition">
如果我更改以下行:
parent = "AttributeDefinition"
到
parent = "Note-noteText"
(注意是一个Class和noteText是I ORIGINALLY在我继承的这个bean中的成员变量 - 但我不想继承Note类,我希望它在我的PurchaseOrderDocument类本地。无论如何,当我在那里有Note-noteText时,我没有得到空指针异常,而是在我的触发器调用“set”方法之后,NOTHING被写入数据库,顺便说一句是ORACLE。)< / p>
因此,这是我摆脱继承的原因,而我希望这个bean是本类的本地。
我的一位同事提到,也许Spring正在寻找FORM中的这个bean,因为我没有在那里 - 它正在考虑它...但我有疑虑。
另请注意我正在使用隐藏控件。当我添加parent =“AttributeDefinition”文本时,我收到一条错误消息,指出我没有指定控件属性。因为,这个bean的内容不是来自USER输入,所以我指定了这个HIDDEN CONTROL属性。
也许这是问题的一部分??
以下是堆栈跟踪 - 以防万一 -
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)
答案 0 :(得分:1)
结果证明上述代码是正确的。
这个问题是我在一个瞬态对象上调用我的setter方法,该方法没有被Spring Framework持久化。 (例如,我在一个对象上调用它,其范围在我调用它的块中结束!)
为了解决这个问题,我只是在另一个范围内的同一个实例上调用了setter。
... Ughh
生活和学习。