在 Tomcat7.0.40 JSF2.1 OF1.4.1 PF3.5 中,我配置了 FacesExceptionFilter 和 FullAjaxExceptionHandlerFactory,如文档 - http://showcase.omnifaces.org/exceptionhandlers/FullAjaxExceptionHandler - http://showcase.omnifaces.org/filters/FacesExceptionFilter
我还添加了 web.xml
<error-page>
<exception-type>java.lang.IndexOutOfBoundsException</exception-type>
<location>/errors/bug.xhtml</location>
</error-page>
登录后,我通过此导航规则进入主页
<navigation-rule>
<from-view-id>/stdPortal/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>mainPortal</from-outcome>
<to-view-id>/stdPortal/stdPages/mainPortal.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
在 mainPortal.xhtml 我有一个图表
<p:poll interval="60" update="graficoPresidio03Top" />
<p:barChart id="graficoPresidio03Top" value="#{mainPortalBean.graficoPresidio03Top}" legendPosition="ne"
style="width:1050px;height:300px" stacked="true" animate="true" xaxisAngle="45" seriesColors="ADFF2F, FFFF00, FFA500, FF4500"/>
</p:panel>
图表每次更新
@ManagedBean
@ViewScoped
public class MainPortalBean implements Serializable {
private static final long serialVersionUID = 5783190881181226264L;
@ManagedProperty( value = "#{user}" )
private UserBean userBean;
public void setUserBean( UserBean userBean ) {
this.userBean = userBean;
}
....
public CartesianChartModel getGraficoPresidio03Top() {
createGraficoPresidio03Top();
return graficoPresidio03Top;
}
我已经更改了一个 for 来创建索引越界异常
private void createGraficoPresidio03() {
//here code with for modified
}
我在 Tomcat LOG 中得到当前响应
lug 01, 2013 12:35:40 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [] threw exception [An error occurred performing resource injection on managed bean mainPortalBean] with root cause
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at com.telenia.tsam.beans.MainPortalBean.createGraficoPresidio03(MainPortalBean.java:815)
at com.telenia.tsam.beans.MainPortalBean.init(MainPortalBean.java:152)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.faces.vendor.WebContainerInjectionProvider.invokeAnnotatedMethod(WebContainerInjectionProvider.java:114)
at com.sun.faces.vendor.WebContainerInjectionProvider.invokePostConstruct(WebContainerInjectionProvider.java:96)
at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:223)
at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:105)
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72)
at org.apache.el.parser.AstValue.getValue(AstValue.java:161)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
at org.primefaces.util.ComponentUtils.getValueToRender(ComponentUtils.java:64)
at org.primefaces.component.spinner.SpinnerRenderer.encodeInput(SpinnerRenderer.java:122)
at org.primefaces.component.spinner.SpinnerRenderer.encodeMarkup(SpinnerRenderer.java:103)
at org.primefaces.component.spinner.SpinnerRenderer.encodeEnd(SpinnerRenderer.java:66)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at org.primefaces.component.tabview.TabViewRenderer.encodeTabContent(TabViewRenderer.java:279)
at org.primefaces.component.tabview.TabViewRenderer.encodeContents(TabViewRenderer.java:237)
at org.primefaces.component.tabview.TabViewRenderer.encodeMarkup(TabViewRenderer.java:127)
at org.primefaces.component.tabview.TabViewRenderer.encodeEnd(TabViewRenderer.java:71)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:63)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:47)
at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:51)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:424)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.telenia.tsam.Filters.NoCacheFilter.doFilter(NoCacheFilter.java:47)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
问题是我没有被重定向到完整的错误页面,而是部分页面错过了很多内容。在我的应用程序中,任何其他异常都得到了正确管理
例如:
lug 01, 2013 1:28:59 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [] threw exception [/stdPortal/stdPages/config/centrale/List.xhtml @147,51 value="#{MM}": /stdPortal/stdPages/config/centrale/List.xhtml @146,103 value="#{cfgCentraleController.resolveMarca(centrale.idMarca)}": Property 'resolveMarca' not found on type com.telenia.tsam.beans.config.centrali.cfgCentraleController] with root cause
javax.el.PropertyNotFoundException: /stdPortal/stdPages/config/centrale/List.xhtml @147,51 value="#{MM}": /stdPortal/stdPages/config/centrale/List.xhtml @146,103 value="#{cfgCentraleController.resolveMarca(centrale.idMarca)}": Property 'resolveMarca' not found on type com.telenia.tsam.beans.config.centrali.cfgCentraleController
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at org.primefaces.component.export.Exporter.exportValue(Exporter.java:131)
at org.primefaces.component.export.CSVExporter.addColumnValue(CSVExporter.java:219)
at org.primefaces.component.export.CSVExporter.exportCells(CSVExporter.java:180)
at org.primefaces.component.export.CSVExporter.exportRow(CSVExporter.java:158)
at org.primefaces.component.export.CSVExporter.exportAll(CSVExporter.java:134)
at org.primefaces.component.export.CSVExporter.export(CSVExporter.java:50)
at org.primefaces.component.export.DataExporter.processAction(DataExporter.java:99)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIData.broadcast(UIData.java:1092)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.telenia.tsam.Filters.NoCacheFilter.doFilter(NoCacheFilter.java:47)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
如何在正确的方向进行调查?在使用 datatable 和lazydatamodel 阅读此FullAjaxExceptionHandler后, 我没有日志,但 Page 得到了正确管理。