{
Iterator<ExceptionQueuedEvent> exceptionQueuedEventIterator = getUnhandledExceptionQueuedEvents().iterator();
while (exceptionQueuedEventIterator.hasNext())
{
ExceptionQueuedEventContext exceptionQueuedEventContext =
(ExceptionQueuedEventContext) exceptionQueuedEventIterator.next().getSource();
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
Throwable throwable = exceptionQueuedEventContext.getException();
String viewId = null;
if (throwable instanceof ViewExpiredException)
{
viewId = ((ViewExpiredException) throwable).getViewId();
}
else if(throwable instanceof ContextNotActiveException)
{
FacesContext facesContext = exceptionQueuedEventContext.getContext();
Flash flash = facesContext.getExternalContext().getFlash();
//the error page uses a cdi scope which isn't active as well
if(flash.containsKey(ContextNotActiveException.class.getName()))
{
break;
}
if(facesContext.getViewRoot() != null)
{
viewId = facesContext.getViewRoot().getViewId();
}
}
if(viewId != null)
{
FacesContext facesContext = exceptionQueuedEventContext.getContext();
UIViewRoot uiViewRoot = facesContext.getApplication().getViewHandler().createView(facesContext, viewId);
if (uiViewRoot == null)
{
continue;