javax.faces.event.ExceptionQueuedEvent Java Examples
The following examples show how to use
javax.faces.event.ExceptionQueuedEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomExceptionHandlerWrapper.java From library with Apache License 2.0 | 6 votes |
/** * Method to handle the generic exception and take a decision of witch step to take after identify the type of the * exception * * All non mapped exceptions on the {@link #customExceptionHandlers} will treated as generic exceptions on the * {@link UndefinedExceptionHandler} */ @SuppressWarnings("unchecked") private void handleException() { final Iterator<ExceptionQueuedEvent> unhandled = getUnhandledExceptionQueuedEvents().iterator(); if (unhandled.hasNext()) { final Throwable throwable = unhandled.next() .getContext() .getException(); unhandled.remove(); final FacesContext context = FacesContext.getCurrentInstance(); final Throwable rootCause = Exceptions.unwrap(throwable); this.customExceptionHandlers.stream() .filter(handler -> handler.accept(rootCause)) .findFirst() .ifPresentOrElse(handler -> handler.handle(context, rootCause), () -> this.undefinedExceptionHandler.handle(context, rootCause)); } }
Example #2
Source File: CustomExceptionHandler.java From admin-template with MIT License | 6 votes |
/** * @param context * @throws Throwable */ private void handleException(FacesContext context) { Iterator<ExceptionQueuedEvent> unhandledExceptionQueuedEvents = getUnhandledExceptionQueuedEvents().iterator(); if (unhandledExceptionQueuedEvents.hasNext()) { Throwable exception = unhandledExceptionQueuedEvents.next().getContext().getException(); unhandledExceptionQueuedEvents.remove(); Throwable rootCause = Exceptions.unwrap(exception); if (rootCause instanceof BusinessException) { handleBusinessException(context, (BusinessException) rootCause); return; } //send user to error page when unexpected exceptions are raised goToErrorPage(context, rootCause); } }
Example #3
Source File: CustomExceptionHandlerWrapper.java From web-budget with GNU General Public License v3.0 | 6 votes |
/** * Method to handle the generic exception and take a decision of witch step to take after identify the type of the * exception * * All non mapped exceptions on the {@link #customExceptionHandlers} will treated as generic exceptions on the * {@link UndefinedExceptionHandler} */ @SuppressWarnings("unchecked") private void handleException() { final Iterator<ExceptionQueuedEvent> unhandled = getUnhandledExceptionQueuedEvents().iterator(); if (unhandled.hasNext()) { final Throwable throwable = unhandled.next() .getContext() .getException(); unhandled.remove(); final FacesContext context = FacesContext.getCurrentInstance(); final Throwable rootCause = Exceptions.unwrap(throwable); this.customExceptionHandlers.stream() .filter(handler -> handler.accept(rootCause)) .findFirst() .ifPresentOrElse(handler -> handler.handle(context, rootCause), () -> this.undefinedExceptionHandler.handle(context, rootCause)); } }
Example #4
Source File: GlobalExceptionHandler.java From oxAuth with MIT License | 6 votes |
public void handle() throws FacesException { final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); while (i.hasNext()) { ExceptionQueuedEvent event = i.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); final FacesContext fc = FacesContext.getCurrentInstance(); final ExternalContext externalContext = fc.getExternalContext(); try { if (isInvalidSessionStateException(t)) { log.error(t.getMessage(), t); performRedirect(externalContext, "/error_session.htm"); } else { log.error(t.getMessage(), t); performRedirect(externalContext, "/error_service.htm"); } fc.renderResponse(); } finally { i.remove(); } } getWrapped().handle(); }
Example #5
Source File: CustomExceptionHandlerWrapper.java From web-budget with GNU General Public License v3.0 | 6 votes |
/** * Method to handle the generic exception and take a decision of witch step to take after identify the type of the * exception * * All non mapped exceptions on the {@link #customExceptionHandlers} will treated as generic exceptions on the * {@link UndefinedExceptionHandler} */ @SuppressWarnings("unchecked") private void handleException() { final Iterator<ExceptionQueuedEvent> unhandled = getUnhandledExceptionQueuedEvents().iterator(); if (unhandled.hasNext()) { final Throwable throwable = unhandled.next() .getContext() .getException(); unhandled.remove(); final FacesContext context = FacesContext.getCurrentInstance(); final Throwable rootCause = Exceptions.unwrap(throwable); this.customExceptionHandlers.stream() .filter(handler -> handler.accept(rootCause)) .findFirst() .ifPresentOrElse(handler -> handler.handle(context, rootCause), () -> this.undefinedExceptionHandler.handle(context, rootCause)); } }
Example #6
Source File: ViewExpiredExceptionExceptionHandler.java From journaldev with MIT License | 6 votes |
@Override public void handle() throws FacesException { for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) { ExceptionQueuedEvent event = i.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); if (t instanceof ViewExpiredException) { ViewExpiredException vee = (ViewExpiredException) t; FacesContext facesContext = FacesContext.getCurrentInstance(); Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap(); NavigationHandler navigationHandler = facesContext.getApplication().getNavigationHandler(); try { // Push some useful stuff to the request scope for use in the page requestMap.put("currentViewId", vee.getViewId()); navigationHandler.handleNavigation(facesContext, null, "/viewExpired"); facesContext.renderResponse(); } finally { i.remove(); } } } // At this point, the queue will not contain any ViewExpiredEvents. Therefore, let the parent handle them. getWrapped().handle(); }
Example #7
Source File: CustomExceptionHandler.java From microprofile-starter with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); while (i.hasNext()) { ExceptionQueuedEvent event = i.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); // get the exception from context Throwable t = context.getException(); FacesContext facesContext = FacesContext.getCurrentInstance(); if (t instanceof ViewExpiredException) { try { String homeLocation = "/index.xhtml"; facesContext.setViewRoot(facesContext.getApplication().getViewHandler().createView(facesContext, homeLocation)); facesContext.getPartialViewContext().setRenderAll(true); String messageText = "Your session is expired and data is resetted."; FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageText, messageText); facesContext.addMessage(null, message); facesContext.renderResponse(); } finally { //remove it from queue i.remove(); } } } //parent handle getWrapped().handle(); }
Example #8
Source File: BridgeExceptionHandlerWrapper.java From deltaspike with Apache License 2.0 | 5 votes |
@Override public void processEvent(SystemEvent event) throws AbortProcessingException { //handle exceptions which occur in a phase-listener (beforePhase) for PhaseId.RENDER_RESPONSE //needed because #handle gets called too late in this case if (event instanceof ExceptionQueuedEvent) { ExceptionQueuedEvent exceptionQueuedEvent = (ExceptionQueuedEvent)event; FacesContext facesContext = exceptionQueuedEvent.getContext().getContext(); if (facesContext.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE && exceptionQueuedEvent.getContext().inBeforePhase()) { Throwable exception = getRootCause(exceptionQueuedEvent.getContext().getException()); if (exception instanceof AccessDeniedException) { processAccessDeniedException(exception); } else { ExceptionToCatchEvent exceptionToCatchEvent = new ExceptionToCatchEvent(exception); exceptionToCatchEvent.setOptional(true); this.beanManager.fireEvent(exceptionToCatchEvent); if (exceptionToCatchEvent.isHandled()) { return; } } } } super.processEvent(event); }
Example #9
Source File: DefaultExceptionHandler.java From spring4-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { log.debug("invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); log.debug("Exception@" + t); log.debug("ExceptionHandlder began."); log.debug("t instanceof FacesException@" + (t instanceof FacesException)); log.debug("t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } if (t instanceof FacesFileNotFoundException|| t instanceof TaskNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } log.debug("ExceptionHandlder end."); getWrapped().handle(); } }
Example #10
Source File: DefaultExceptionHandler.java From ee7-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { log.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); log.log(Level.INFO, "Exception@" + t); log.log(Level.INFO, "ExceptionHandlder began."); log.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } if (t instanceof FacesFileNotFoundException || t instanceof TaskNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } log.log(Level.INFO, "ExceptionHandlder end."); getWrapped().handle(); } }
Example #11
Source File: GlobalExceptionHandler.java From oxTrust with MIT License | 5 votes |
public void handle() throws FacesException { final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); while (i.hasNext()) { ExceptionQueuedEvent event = i.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); final FacesContext fc = FacesContext.getCurrentInstance(); final ExternalContext externalContext = fc.getExternalContext(); try { if (isSecurityException(t)) { performRedirect(externalContext, "/login.htm"); } else if (isConversationException(t)) { log.trace(t.getMessage(), t); performRedirect(externalContext, "/conversation_error.htm"); } if (isViewExpiredException(t)) { storeRequestURI(); performRedirect(externalContext, "/login.htm"); } else { log.trace(t.getMessage(), t); performRedirect(externalContext, "/error.htm"); } fc.renderResponse(); } finally { i.remove(); } } getWrapped().handle(); }
Example #12
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof FacesFileNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #13
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof FacesFileNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #14
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof FacesFileNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #15
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof FacesFileNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #16
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof FacesFileNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #17
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof FacesFileNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #18
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof FacesFileNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #19
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof FacesFileNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #20
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof FacesFileNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #21
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof FacesFileNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #22
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException)); // log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException)); t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof FacesFileNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #23
Source File: DefaultExceptionHandler.java From javaee8-jsf-sample with GNU General Public License v3.0 | 5 votes |
@Override public void handle() throws FacesException { LOG.log(Level.INFO, "invoking custom ExceptionHandlder..."); Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator(); while (events.hasNext()) { ExceptionQueuedEvent event = events.next(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); Throwable t = context.getException(); LOG.log(Level.INFO, "Exception@" + t.getClass().getName()); LOG.log(Level.INFO, "ExceptionHandlder began."); //t.printStackTrace(); if (t instanceof ViewExpiredException) { try { handleViewExpiredException((ViewExpiredException) t); } finally { events.remove(); } } else if (t instanceof TaskNotFoundException) { try { handleNotFoundException((Exception) t); } finally { events.remove(); } } else { getWrapped().handle(); } LOG.log(Level.INFO, "ExceptionHandlder end."); } }
Example #24
Source File: WebUtil.java From ctsms with GNU Lesser General Public License v2.1 | 4 votes |
public static void publishException(Exception e) { FacesContext context = FacesContext.getCurrentInstance(); ExceptionQueuedEventContext eventContext = new ExceptionQueuedEventContext(context, e); eventContext.getAttributes().put(EVENT_CONTEXT_VIEW_ID, context.getViewRoot().getViewId()); context.getApplication().publishEvent(context, ExceptionQueuedEvent.class, eventContext); }
Example #25
Source File: CustomExceptionHandler.java From sailfish-core with Apache License 2.0 | 4 votes |
@Override public void handle() throws FacesException { Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); while (i.hasNext()) { ExceptionQueuedEvent event = i.next(); ExceptionQueuedEventContext context = event.getContext(); Throwable t = context.getException(); logger.error(t.getMessage(), t); } wrapped.handle(); }
Example #26
Source File: DefaultErrorViewAwareExceptionHandlerWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public void handle() throws FacesException { lazyInit(); Iterator<ExceptionQueuedEvent> exceptionQueuedEventIterator = getUnhandledExceptionQueuedEvents().iterator(); while (exceptionQueuedEventIterator.hasNext()) { ExceptionQueuedEventContext exceptionQueuedEventContext = (ExceptionQueuedEventContext) exceptionQueuedEventIterator.next().getSource(); @SuppressWarnings({ "ThrowableResultOfMethodCallIgnored" }) Throwable throwable = exceptionQueuedEventContext.getException(); String viewId = null; if (!isExceptionToHandle(throwable)) { continue; } FacesContext facesContext = exceptionQueuedEventContext.getContext(); Flash flash = facesContext.getExternalContext().getFlash(); if (throwable instanceof ViewExpiredException) { viewId = ((ViewExpiredException) throwable).getViewId(); } else if (throwable instanceof ContextNotActiveException) { //the error page uses a cdi scope which isn't active as well //(it's recorded below - see flash.put(throwable.getClass().getName(), throwable);) if (flash.containsKey(ContextNotActiveException.class.getName())) { //TODO show it in case of project-stage development break; } if (facesContext.getViewRoot() != null) { viewId = facesContext.getViewRoot().getViewId(); } else { viewId = BeanProvider.getContextualReference(ViewConfigResolver.class) //has to return a value otherwise this handler wouldn't be active .getDefaultErrorViewConfigDescriptor().getViewId(); } } if (viewId != null) { UIViewRoot uiViewRoot = facesContext.getApplication().getViewHandler().createView(facesContext, viewId); if (uiViewRoot == null) { continue; } if (facesContext.isProjectStage(javax.faces.application.ProjectStage.Development) || ProjectStageProducer.getInstance().getProjectStage() == ProjectStage.Development || ProjectStageProducer.getInstance().getProjectStage() instanceof TestStage) { throwable.printStackTrace(); } facesContext.setViewRoot(uiViewRoot); exceptionQueuedEventIterator.remove(); //record the current exception -> to check it at the next call or to use it on the error-page flash.put(throwable.getClass().getName(), throwable); flash.keep(throwable.getClass().getName()); this.viewNavigationHandler.navigateTo(DefaultErrorView.class); break; } } this.wrapped.handle(); }