我正在使用JSF 2.1和JBOSS eap6.1 Primefaces 5.2
我想创建一个网站,允许用户输入项目并将其添加到表格中。在我超过表中的200个项目之后,性能不再好了,因为每次添加我都需要更新表以查看最近添加的项目。但是现在我在达到230 ROWS后更新表时遇到了NullPointerException,直到229行才能正常工作:
09:29:25,475 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/JETMealOrder].[Faces Servlet]] (http-localhost/127.0.0.1:8088-6) JBWEB000236: Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:443) [jsf-impl-2.1.19-redhat-1.jar:2.1.19-redhat-1]
at com.sun.faces.context.PartialViewContextImpl.access$300(PartialViewContextImpl.java:72) [jsf-impl-2.1.19-redhat-1.jar:2.1.19-redhat-1]
at com.sun.faces.context.PartialViewContextImpl$DelayedInitPartialResponseWriter.getWrapped(PartialViewContextImpl.java:577) [jsf-impl-2.1.19-redhat-1.jar:2.1.19-redhat-1]
at javax.faces.context.PartialResponseWriter.startDocument(PartialResponseWriter.java:115) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]
at org.primefaces.context.PrimePartialResponseWriter.startDocument(PrimePartialResponseWriter.java:146) [primefaces-5.2.jar:5.2]
at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:199) [jsf-impl-2.1.19-redhat-1.jar:2.1.19-redhat-1]
at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:124) [jsf-impl-2.1.19-redhat-1.jar:2.1.19-redhat-1]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.19-redhat-1.jar:2.1.19-redhat-1]
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.19-redhat-1.jar:2.1.19-redhat-1]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.19-redhat-1.jar:2.1.19-redhat-1]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100) [primefaces-5.2.jar:5.2]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_45]
代码:
<p:dataTable tableStyle="width:auto" id="items" var="p"
widgetVar="itemstbl" value="#{viewOrder.order.opNonMenus}"
editMode="cell" editable="#{viewOrder.readonly==false}"
rowKey="#{p.serial}" draggableRows="#{viewOrder.readonly==false}"
sortBy="#{p.serial}">
<p:ajax event="rowReorder" update="form:items"
listener="#{viewOrder.onRowReorder}" />
<f:facet name="header">Meal Order Details</f:facet>
<p:column headerText="S.No." style="width:25px">
<h:outputText value="#{p.serial}" />
</p:column>
<p:column headerText="Item Code">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{(p.withCode==1)? p.itemCode : '@FLP'}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{p.itemCode}" id="code"
onblur="value = value.toUpperCase()">
<p:ajax event="blur" update="items"
listener="#{viewOrder.validateNonMenu(p)}" />
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Item Description">
<p:cellEditor>
<f:facet name="output">
<h:outputText id="qdesc" value="#{p.itemDesc}" />
</f:facet>
<f:facet name="input">
<p:inputTextarea value="#{p.itemDesc}" autoResize="true"
cols="30" placeholder="Item Description" rows="1" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Class">
<p:cellEditor>
<f:facet name="output">
<h:outputText id="qclass" value="#{p.classCode.toUpperCase()}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{p.classCode}"
onblur="value = value.toUpperCase()" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="UOM">
<p:cellEditor>
<f:facet name="output">
<h:outputText id="quom" value="#{p.uom}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{p.uom}"
onblur="value = value.toUpperCase()">
<p:ajax event="blur" update="form:items:0:code" />
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Group">
<p:cellEditor>
<f:facet name="output">
<h:outputText id="qgrp" value="#{p.groupClass}" />
</f:facet>
<f:facet name="input">
<p:autoComplete forceSelection="false" var="group"
itemLabel="#{group}" itemValue="#{group}"
value="#{p.groupClass}"
completeMethod="#{viewOrder.completeQqcGroup}">
<f:facet name="itemtip">
<h:outputText value="#{group}" />
</f:facet>
</p:autoComplete>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Item Cost">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{p.purCost}" />
</f:facet>
<f:facet name="input">
<p:inputText readonly="#{p.withCode==1}"
onkeypress="var key = window.event ? event.keyCode : event.which; if (event.keyCode == 8 || event.keyCode == 46 || event.keyCode == 37 || event.keyCode == 39) return true; else if (key & lt; 48 || key & gt; 57) return false;"
value="#{p.purCost}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Quantity">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{p.qtyItem}" />
</f:facet>
<f:facet name="input">
<p:inputText
onkeypress="var key = window.event ? event.keyCode : event.which; if (event.keyCode == 8 || event.keyCode == 46 || event.keyCode == 37 || event.keyCode == 39) return true; else if (key & lt; 48 || key & gt; 57) return false;"
value="#{p.qtyItem}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:32px;text-align: center"
headerText="Image">
<p:commandButton update="form:cpsDetail"
oncomplete="PF('cpsinfo').show()" icon="ui-icon-image"
title="View Image">
<f:setPropertyActionListener value="#{p}"
target="#{viewOrder.selectedItem}" />
</p:commandButton>
</p:column>
<p:column style="width:32px;text-align: center"
headerText="Replace">
<p:commandButton rendered="#{viewOrder.readonly==false}"
update="form:rrepotbl" icon="ui-icon-refresh"
widgetVar="rplbtn" title="Replace Item"
oncomplete="PF('rdlg').show();">
<f:setPropertyActionListener value="#{p}"
target="#{viewOrder.replaceItem}" />
</p:commandButton>
</p:column>
<p:column style="width:32px;text-align: center"
headerText="Replace by Menu">
<p:commandButton rendered="#{viewOrder.readonly==false}"
update="form:rMrepotbl" icon="ui-icon-refresh"
widgetVar="rplbtn" title="Replace Item"
oncomplete="PF('rMdlg').show();">
<f:setPropertyActionListener value="#{p}"
target="#{viewOrder.replaceItem}" />
</p:commandButton>
</p:column>
<p:column style="width:32px;text-align: center"
headerText="Delete">
<p:commandButton rendered="#{viewOrder.readonly==false}"
update="form:items" action="#{viewOrder.delete}"
icon="ui-icon-close" title="Delete Item">
<f:setPropertyActionListener value="#{p}"
target="#{viewOrder.selectedItem}" />
</p:commandButton>
</p:column>
</p:dataTable>
public void addNewItem() {
OpNonMenu item = new OpNonMenu();
item.setDblDate(order.getDblDate());
item.setFlightNoD(order.getFltNoD());
item.setCustomerCode(cust.getCode());
item.setMainSbdCode(order.getMainSbdCode());
item.setSalesEditBy(log.getUserId());
item.setSalesEditDate(order.getEditDate());
item.setSerial(order.getOpNonMenus().size() + 1);
item.setEditBy(order.getEditBy());
item.setEditDate(order.getEditDate());
item.setClassCode("");
item.setWithCode(0);
item.setItemCode("@FLP");
item.setItemType("S");
order.addOpNonMenu(item);
}
答案 0 :(得分:0)
我通过增加JBOSS服务器中standalone.xml中的max count属性解决了空指针异常的问题
<system-properties>
<property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="10000"/>
</system-properties>
但是没有行增加后性能仍然会变差。