1

我正在向业务对象添加一个新 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"

(Note 是一个类,noteText 是我最初在这个 bean 中继承的成员变量 - 但我不想再从 Note 类继承,我希望它在我的 PurchaseOrderDocument 类本地。无论如何,当我在那里有 Note-noteText,我没有得到空指针异常,而是在我的触发器调用“set”方法之后,没有将任何内容写入数据库,顺便说一下是 ORACLE。)

因此,这就是我放弃继承的原因,相反我希望这个 bean 对这个类是本地的。

我的一位同事提到,也许 Spring 正在 FORM 中寻找这个 bean,因为我没有它 - 它正在呕吐......但我有疑问。

另请注意,我正在使用隐藏控件。当我添加 parent="AttributeDefinition" 文本时,我收到一条错误消息,指出我没有指定控件属性。因为,这个 bean 不是从 USER 输入获取它的内容,所以我指定了这个 HIDDEN CONTROL 属性。

也许这是问题的一部分??

这是堆栈跟踪以防万一-

堆栈跟踪:
    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)

根本原因

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)

根本原因

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)
4

1 回答 1

1

事实证明,上面的代码是正确的。

这个问题是我在一个没有被 Spring 框架持久化的瞬态对象上调用我的 setter 方法。(例如,我在一个对象上调用它,该对象的范围在我调用它的块中结束!)

为了解决这个问题,我只是在范围内的同一类的另一个实例上调用了 setter。

呃……

活到老,学到老。

于 2012-11-02T18:15:11.487 回答