我们有一个自定义的 JSF2 异常处理程序......
Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();
boolean isUnHandledException = false;
SystemException se = null;
while(i.hasNext()) {
ExceptionQueuedEvent event = (ExceptionQueuedEvent)i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext)event.getSource();
Throwable t = context.getException();
try {
if (apperror)
take to app error page
if (filenotfound)
take to page not found error page
}catch(){
} finally {
i.remove ().....causes problem....in filenot found...
.....
}
应用程序异常处理工作正常,没有任何问题。
但是我们自定义处理程序中的 FileNotFound 会导致问题。异常处理程序捕获 FileNotFound ,但是在尝试删除 queuedevent i.remove 时会导致 NullPointerException ,如果我评论 i.remove 它工作正常...
java.lang.NullPointerException
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:96)
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 weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)