private Response causeToResponse(EJBException exception) { final Exception cause = exception.getCausedByException(); if (cause != null) { final ExceptionMapper mapper = mappers.get().findMapping(cause); if (mapper != null && mapper != this) { return mapper.toResponse(cause); } else if (cause instanceof WebApplicationException) { return ((WebApplicationException) cause).getResponse(); } } return null; } }
Java Code /** * Returns the root cause of the given exception, defined as the first * cause that is not an <tt>EJBException</tt> or the last cause in the chain. * * @param exception <tt>EJBException</tt> to inspect * @return the root cause of the exception */ public static Exception getRootCause ( EJBException exception ) { if ( null == exception ) { return null; } EJBException effect = exception; Exception cause = effect.getCausedByException(); while ( null != cause && cause instanceof EJBException ) { effect = (EJBException) cause; cause = effect.getCausedByException(); } return null == cause ? effect : cause; }
/** * Detects exception contains is or a ApplicationDeadlockException. */ public static ApplicationDeadlockException isADE(Throwable t) { while (t!=null) { if (t instanceof ApplicationDeadlockException) { return (ApplicationDeadlockException)t; } else if (t instanceof RemoteException) { t = ((RemoteException)t).detail; } else if (t instanceof EJBException) { t = ((EJBException)t).getCausedByException(); } else { return null; } } return null; }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { return method.invoke(innerInstance, args); } catch (EJBException e) { if(unwrapEjbException.get()) { throw e.getCausedByException(); } else { throw e; } } } });
private JoynrException getJoynrExceptionFromInvocationException(InvocationTargetException e) throws InvocationTargetException { JoynrException joynrException = null; if (e.getCause() instanceof EJBException) { // an EJBException is only thrown when the exception is not in the throws declaration // ApplicationExceptions are always declared with throw and thus EJBExceptions won't be caused by them. Exception exception = ((EJBException) e.getCause()).getCausedByException(); if (exception instanceof ProviderRuntimeException) { joynrException = (ProviderRuntimeException) exception; } else { joynrException = new ProviderRuntimeException("Unexpected exception from provider: " + (exception == null ? e.getCause().toString() : exception.toString())); } } else if (e.getCause() instanceof ProviderRuntimeException || e.getCause() instanceof ApplicationException) { joynrException = (JoynrException) e.getCause(); } if (joynrException == null) { throw e; } LOG.trace("Returning joynr exception: {}", joynrException); return joynrException; }
/** * Exception mapping * @param exception * @return HTTP response */ @Override public Response toResponse(EJBException exception) { Exception e = exception.getCausedByException(); if (e instanceof AeroGearSecurityException) { AeroGearSecurityException ex = (AeroGearSecurityException) e; return Response.status(ex.getStatus()) .entity(ex.getMessage()) .build(); } return Response.status(BAD_REQUEST).build(); }
public void test04_throwSystemException(){ try{ ejbLocalObject.throwSystemException_NullPointer(); } catch (EJBException e){ //Good, so far. assertNotNull("Nested exception should not be is null", e ); assertTrue("Nested exception should be an instance of NullPointerException, but exception is "+e.getCausedByException().getClass().getName(), (e.getCausedByException() instanceof NullPointerException)); return; } catch (Throwable e){ fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); } fail("An EJBException encapsulating a NullPointerException should have been thrown."); }
public void test04_throwSystemException(){ try{ ejbLocalObject.throwSystemException_NullPointer(); } catch (final EJBException e){ //Good, so far. assertNotNull("Nested exception should not be is null", e ); assertTrue("Nested exception should be an instance of NullPointerException, but exception is "+e.getCausedByException().getClass().getName(), (e.getCausedByException() instanceof NullPointerException)); return; } catch (final Throwable e){ fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); } fail("An EJBException encapsulating a NullPointerException should have been thrown."); }
public void test04_throwSystemException(){ try{ ejbLocalObject.throwSystemException_NullPointer(); } catch (EJBException e){ //Good, so far. assertNotNull("Nested exception should not be is null", e ); assertTrue("Nested exception should be an instance of NullPointerException, but exception is "+e.getCausedByException().getClass().getName(), (e.getCausedByException() instanceof NullPointerException)); return; } catch (Throwable e){ fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); } fail("An EJBException encapsulating a NullPointerException should have been thrown."); }
/** * méthode utilitaire dont le role est de représenter les exceptions encapsulées sous forme d'une * collection. L'exception courante se trouvera en première position de la collection. Les * eventuelles imbrications succéssive suivront dans la liste. * * @param e L'exception de plus haut niveau * @return une collection de Throwable, qui contiendra au moins l'exception passee en parametre. * Et plus si cette exception en imbrique d'autre. */ public static Collection<Throwable> getChainedExceptions(Throwable e) { List<Throwable> result = new ArrayList<Throwable>(); Throwable throwable = e; while (throwable != null) { result.add(throwable); if (throwable instanceof WithNested) { throwable = ((WithNested) throwable).getNested(); } else if (throwable instanceof RemoteException) { throwable = ((RemoteException) throwable).detail; } else if (throwable instanceof EJBException) { throwable = ((EJBException) throwable).getCausedByException(); } else { throwable = null; } } return result; } }
public void test04_throwSystemException(){ try{ ejbLocalObject.throwSystemException_NullPointer(); } catch (final EJBException e){ //Good, so far. assertNotNull("Nested exception should not be is null", e ); assertTrue("Nested exception should be an instance of NullPointerException, but exception is "+e.getCausedByException().getClass().getName(), (e.getCausedByException() instanceof NullPointerException)); return; } catch (final Throwable e){ fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); } fail("An EJBException encapsulating a NullPointerException should have been thrown."); }
public Response toResponse(EJBException exception) { final Exception cause = exception.getCausedByException(); if (cause != null) { final ExceptionMapper mapper = providers.getExceptionMapper(cause.getClass()); if (mapper != null) { return mapper.toResponse(cause); } else if (cause instanceof WebApplicationException) { return ((WebApplicationException)cause).getResponse(); } } // Re-throw so the exception can be passed through to the // servlet container throw new MappableContainerException((cause == null) ? exception : cause); } }
public Response toResponse(EJBException exception) { final Exception cause = exception.getCausedByException(); if (cause != null) { final ExceptionMapper mapper = providers.getExceptionMapper(cause.getClass()); if (mapper != null) { return mapper.toResponse(cause); } else if (cause instanceof WebApplicationException) { return ((WebApplicationException)cause).getResponse(); } } // Re-throw so the exception can be passed through to the // servlet container throw new MappableContainerException((cause == null) ? exception : cause); } }
public Response toResponse(EJBException exception) { final Exception cause = exception.getCausedByException(); if (cause != null) { final ExceptionMapper mapper = providers.getExceptionMapper(cause.getClass()); if (mapper != null) { return mapper.toResponse(cause); } else if (cause instanceof WebApplicationException) { return ((WebApplicationException)cause).getResponse(); } } // Re-throw so the exception can be passed through to the // servlet container throw new MappableContainerException((cause == null) ? exception : cause); } }
ra = ctxt.roleAssignees().getRoleAssignee(rai); } catch ( EJBException iae ) { if ( iae.getCausedByException() instanceof IllegalArgumentException ) { throw new IllegalCommandException("Bad role assignee name:" + rai, this);
return false; cause = ((EJBException) cause).getCausedByException();
return false; cause = ((EJBException) cause).getCausedByException();
throw new CommandException("Command " + aCommand.toString() + " failed: " + ejbe.getMessage(), ejbe.getCausedByException(), aCommand);
alr.setActionResult(ActionLogRecord.Result.InternalError); 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);
(((EJBException) cause).getCausedByException() != null)) cause = ((EJBException) cause).getCausedByException(); if (ejbException.getCausedByException() != null) ejbException.getCausedByException());