@Interceptor @InterceptEJBExceptions public class EjbExceptionInterceptor { @AroundInvoke public Object interceptBubblingExceptions(final InvocationContext context) throws Exception { try { return context.proceed(); } catch (MySpecificEJBException msejbe) { Object[] args = { msejbe.getErrorCode(), msejbe.getMethodSignature(), msejbe.getParameters()}; // This would create a FacesMessage in JSF addErrorMessageToFacesContext(null, summary_template, details_template, args); } catch (EJBException ejbe) { super.addErrorMessageToFacesContext(null, "Unspecified EJBException", ejbe.getMessage()); } // "Pure" RuntimeExceptions will fall through and will be shown on 'error-page' specified in web.xml return null; } }
@Override public Response toResponse(EJBException exception) { if (exception instanceof EJBTransactionRequiredException) { return Response.status(412).entity(TRANSACTIONA_REQUIRED_MESSAGE).build(); } else if (exception.getMessage().contains("WFLYEJB0063")) { return Response.status(412).entity(INVALID_TRANSACTIONA_MESSAGE).build(); } throw exception; }
private UIComponent component; public UIComponent getComponent() { return component; } public void setComponent(UIComponent component) { this.component = component; } public String login(){ try{ ad= adminEJB.verifyUser( username,password); If(ad!=null) return="welcome"; else { FacesContext context = FacesContext. getCurrentInstance(); context.addMessage(component.getClientId(), new FacesMessage("Login Failed")); return "login"; } }catch(EJBException e){ FacesContext context = FacesContext.getCurrentInstance(); context.addMessage(component.getClientId(), new FacesMessage(e.getMessage())); return "login"; } }
return null; } catch (EJBException e) { logger.log(Level.WARNING, "EJBException exception: {0}", e.getMessage()); return null;
/** * Validates that this instance is of the correct implementation class * of a local interface. * Throws IllegalArgumentException if the passed * argument is of a wrong type. * * @param o the instance to validate. * @param beanName as String. * @throws IllegalArgumentException if validation fails. */ protected void assertInstanceOfLocalInterfaceImpl(Object o, String beanName) { // We can't check if null is the correct type or not. So // we let it succeed. if (o == null) return; try { CMPHelper.assertValidLocalObject(o, getContainer()); } catch (EJBException ex) { String msg = I18NHelper.getMessage(messages, "EXC_WrongLocalInstance", // NOI18N new Object[] {o.getClass().getName(), beanName, ex.getMessage()}); logger.log(Logger.WARNING, msg); throw new IllegalArgumentException(msg); } }
/** * Validates that this instance is of the correct implementation class * of bean remote interface. * Throws IllegalArgumentException if the argument is of a wrong type. * * @param o the instance to validate. * @param beanName as String. * @throws IllegalArgumentException if validation fails. */ protected void assertInstanceOfRemoteInterfaceImpl(Object o, String beanName) { // We can't check if null is the correct type or not. So // we let it succeed. if (o == null) return; try { CMPHelper.assertValidRemoteObject(o, getContainer()); } catch (EJBException ex) { String msg = I18NHelper.getMessage(messages, "EXC_WrongRemoteInstance", // NOI18N new Object[] {o.getClass().getName(), beanName, ex.getMessage()}); logger.log(Logger.WARNING, msg); throw new IllegalArgumentException(msg); } }
StringBuilder error = new StringBuilder(); error.append(ex).append(" "); error.append(ex.getMessage()).append(" "); Throwable cause = ex; while (cause.getCause() != null) {
error.append(ex.getMessage()).append(" ");
throw new CommandException("Command " + aCommand.toString() + " failed: " + ejbe.getMessage(), ejbe.getCausedByException(), aCommand);
logger.severe(ex.getMessage()); return false;
StringBuilder error = new StringBuilder(); error.append(ex).append(" "); error.append(ex.getMessage()).append(" "); Throwable cause = ex; while (cause.getCause() != null) {
throw NoSuchObjectExceptionHelper.create(e); } catch (javax.ejb.EJBException e) { RemoteException re = new RemoteException(e.getMessage()); re.detail = e; throw re;
/** * postInvoke for Remote access * @param rctx The RequestCtx that was returne t preInvoke() * @throws TransactionRequiredException * @throws TransactionRolledbackException * @throws NoSuchObjectException * @throws RemoteException postinvoke failed */ public void postInvokeRemote(RequestCtx rctx) throws RemoteException { if (TraceEjb.isDebugIc()) { TraceEjb.interp.log(BasicLevel.DEBUG, ""); } try { postInvoke(rctx); } catch (javax.ejb.TransactionRequiredLocalException e) { throw new javax.transaction.TransactionRequiredException(e.getMessage()); } catch (javax.ejb.TransactionRolledbackLocalException e) { throw new javax.transaction.TransactionRolledbackException(e.getMessage()); } catch (javax.ejb.NoSuchObjectLocalException e) { throw new java.rmi.NoSuchObjectException(e.getMessage()); } catch (javax.ejb.EJBException e) { throw new java.rmi.RemoteException(e.getMessage(), e); } }
alr.setInfo( alr.getInfo() + "// " + ejbx.getMessage()); if ( ejbx.getCausedByException() instanceof IllegalArgumentException ) { return error(Status.BAD_REQUEST, "Bad request: can't save user. " + ejbx.getCausedByException().getMessage()); } else { logger.log(Level.WARNING, "Error saving user: ", ejbx); return error(Status.INTERNAL_SERVER_ERROR, "Can't save user: " + ejbx.getMessage());
StringBuilder error = new StringBuilder(); error.append(ex).append(" "); error.append(ex.getMessage()).append(" "); Throwable cause = ex; while (cause.getCause()!= null) { } catch (EJBException ex) { saveError.append(ex).append(" "); saveError.append(ex.getMessage()).append(" "); Throwable cause = ex; while (cause.getCause() != null) {
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "Exception caught calling ingestService.createDataFiles. No cause: " + ex.getMessage());
StringBuilder error = new StringBuilder(); error.append(ex).append(" "); error.append(ex.getMessage()).append(" "); Throwable cause = ex; while (cause.getCause()!= null) {