private void handleException(final Environment environment, final Job job, final Throwable exception) { final Transaction transaction = environment.get(Transaction.class); final JobExceptionHandler handler = new JobExceptionHandler(job.getId(), exception, this.eventExecutor.getCommandService()); transaction.registerSynchronization(handler); if (exception instanceof RuntimeException) { throw (RuntimeException) exception; } throw new BonitaRuntimeException("Execution of job (" + job + ") failed: " + exception.getMessage(), exception); }