Package org.quartz

Examples of org.quartz.JobExecutionException


        BackgroundEnvironment env;
    try {
      env = new BackgroundEnvironment(logger, envContext, manager);
    } catch (MalformedURLException mue) {
      // Unlikely to happen
      throw new JobExecutionException(mue);
    }
        CocoonComponentManager.enterEnvironment(env, env.getManager(), env.getProcessor());
        boolean release = false;
        try {
            jobrole = (String)data.get(QuartzJobScheduler.DATA_MAP_ROLE);
View Full Code Here


        }
      });
    } catch (InterruptedException e) {
      LOG.log(Level.WARNING, "Interrupted while trying to launch cron " + path, e);
      Thread.currentThread().interrupt();
      throw new JobExecutionException(e);
    }
  }
View Full Code Here

    @SuppressWarnings("unchecked")
    private void doExecute(JobInfo ji) throws JobExecutionException {
        JobProcessor processor = _processor;
        if (processor == null)
            throw new JobExecutionException("No processor.", null, true);
        try {
            processor.onScheduledJob(ji);
        } catch (JobProcessorException jpe) {
            throw new JobExecutionException(jpe, jpe.retry);
        } catch (RuntimeException ex) {
            __log.error("Scheduled transaction failed unexpectedly: transaction will not be retried!.", ex);
            throw new JobExecutionException(ex, true);
        } catch (Throwable t) {
            __log.fatal("Scheduled transaction failed unexpectedly: transaction will not be retried!.", t);
            throw new JobExecutionException(false);
        }
    }
View Full Code Here

        try {
            getLoadBalancer().process(exchange);

            if (exchange.getException() != null) {
                // propagate the exception back to Quartz
                throw new JobExecutionException(exchange.getException());
            }
        } catch (Exception e) {
            // log the error
            LOG.error(ExchangeHelper.createExceptionMessage("Error processing exchange", exchange, e));

            // and rethrow to let quartz handle it
            if (e instanceof JobExecutionException) {
                throw (JobExecutionException) e;
            }
            throw new JobExecutionException(e);
        }
    }
View Full Code Here

public class CamelJob implements Job {

    public void execute(JobExecutionContext context) throws JobExecutionException {
        QuartzEndpoint endpoint = (QuartzEndpoint) context.getJobDetail().getJobDataMap().get(QuartzConstants.QUARTZ_ENDPOINT);
        if (endpoint == null) {
            throw new JobExecutionException("No quartz endpoint available for key: " + QuartzConstants.QUARTZ_ENDPOINT);
        }
        endpoint.onJobExecute(context);
    }
View Full Code Here

      pvs.addPropertyValues(scheduler.getContext());
      pvs.addPropertyValues(mergedJobDataMap);
      bw.setPropertyValues(pvs, true);
    }
    catch (SchedulerException ex) {
      throw new JobExecutionException(ex);
    }
    executeInternal(context);
  }
View Full Code Here

      pvs.addPropertyValues(scheduler.getContext());
      pvs.addPropertyValues(mergedJobDataMap);
      bw.setPropertyValues(pvs, true);
    }
    catch (SchedulerException ex) {
      throw new JobExecutionException(ex);
    }
    executeInternal(context);
  }
View Full Code Here

        logger.debug("start");
       
        targetBean = context.getMergedJobDataMap().getString("targetBean");
        logger.debug("targetBean is "+targetBean);
        if(targetBean==null)
          throw new JobExecutionException("targetBean cannot be null.", false);
       
        targetMethod = context.getMergedJobDataMap().getString("targetMethod");
        logger.debug("targetMethod is "+targetMethod);
        if(targetMethod==null)
          throw new JobExecutionException("targetMethod cannot be null.", false);
       
        // when org.quartz.jobStore.useProperties=="true" the arguments entry (which should be an Object[]) in the JobDataMap gets converted into a String.
        Object argumentsObject = context.getMergedJobDataMap().get("arguments");
        Object[] arguments = (argumentsObject instanceof String) ? null : (Object[])argumentsObject;
        logger.debug("arguments array is "+arguments);
       
        Object bean = applicationContext.getBean(targetBean);
        logger.debug("applicationContext resolved bean name/id '"+targetBean+"' to "+bean);
       
        MethodInvoker beanMethod = new MethodInvoker();
        beanMethod.setTargetObject(bean);
        beanMethod.setTargetMethod(targetMethod);
        beanMethod.setArguments(arguments);
        beanMethod.prepare();
       
        logger.debug("Invoking Bean: "+targetBean+"; Method: "+targetMethod+"; arguments: "+arguments+";");
       
        beanMethod.invoke();
      }catch(JobExecutionException e){
        throw e;
      }catch(Exception e){
        logger.error("定时任务[bean="+targetBean
            +",method="+targetMethod+"]执行异常:",e);
        throw new JobExecutionException(e);
      }finally{
        logger.debug("end");
      }
    }
View Full Code Here

        try {
            balancer.process(exchange);

            if (exchange.getException() != null) {
                // propagate the exception back to Quartz
                throw new JobExecutionException(exchange.getException());
            }
        } catch (Exception e) {
            // log the error
            LOG.error(ExchangeHelper.createExceptionMessage("Error processing exchange", exchange, e));

            // and rethrow to let quartz handle it
            if (e instanceof JobExecutionException) {
                throw (JobExecutionException) e;
            }
            throw new JobExecutionException(e);
        }
    }
View Full Code Here

        }
    }

    protected String executeWithSecurityContext(final boolean dryRun) throws JobExecutionException {
        if (!(task instanceof SyncTask)) {
            throw new JobExecutionException("Task " + taskId + " isn't a SyncTask");
        }
        final SyncTask syncTask = (SyncTask) this.task;

        Connector connector;
        try {
            connector = connFactory.getConnector(syncTask.getResource());
        } catch (Exception e) {
            final String msg = String.format("Connector instance bean for resource %s and connInstance %s not found",
                    syncTask.getResource(), syncTask.getResource().getConnector());

            throw new JobExecutionException(msg, e);
        }

        UMapping uMapping = syncTask.getResource().getUmapping();
        if (uMapping != null && uMapping.getAccountIdItem() == null) {
            throw new JobExecutionException("Invalid user account id mapping for resource " + syncTask.getResource());
        }
        RMapping rMapping = syncTask.getResource().getRmapping();
        if (rMapping != null && rMapping.getAccountIdItem() == null) {
            throw new JobExecutionException("Invalid role account id mapping for resource " + syncTask.getResource());
        }
        if (uMapping == null && rMapping == null) {
            return "No mapping configured for both users and roles: aborting...";
        }

        LOG.debug("Execute synchronization with token {}", syncTask.getResource().getUsyncToken());

        final List<SyncResult> results = new ArrayList<SyncResult>();

        final SyncPolicy syncPolicy = syncTask.getResource().getSyncPolicy();
        final ConflictResolutionAction resAct = syncPolicy == null || syncPolicy.getSpecification() == null
                ? ConflictResolutionAction.IGNORE
                : ((SyncPolicySpec) syncPolicy.getSpecification()).getConflictResolutionAction();

        // Prepare handler for SyncDelta objects
        final SyncopeSyncResultHandler handler =
                (SyncopeSyncResultHandler) ((DefaultListableBeanFactory) ApplicationContextProvider.
                getApplicationContext().getBeanFactory()).createBean(
                        SyncopeSyncResultHandler.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
        handler.setConnector(connector);
        handler.setActions(actions);
        handler.setDryRun(dryRun);
        handler.setResAct(resAct);
        handler.setResults(results);
        handler.setSyncTask(syncTask);

        actions.beforeAll(handler);
        try {
            SyncToken latestUSyncToken = null;
            if (uMapping != null && !syncTask.isFullReconciliation()) {
                latestUSyncToken = connector.getLatestSyncToken(ObjectClass.ACCOUNT);
            }
            SyncToken latestRSyncToken = null;
            if (rMapping != null && !syncTask.isFullReconciliation()) {
                latestRSyncToken = connector.getLatestSyncToken(ObjectClass.GROUP);
            }

            if (syncTask.isFullReconciliation()) {
                if (uMapping != null) {
                    connector.getAllObjects(ObjectClass.ACCOUNT, handler,
                            connector.getOperationOptions(uMapping.getItems()));
                }
                if (rMapping != null) {
                    connector.getAllObjects(ObjectClass.GROUP, handler,
                            connector.getOperationOptions(rMapping.getItems()));
                }
            } else {
                if (uMapping != null) {
                    connector.sync(ObjectClass.ACCOUNT, syncTask.getResource().getUsyncToken(), handler,
                            connector.getOperationOptions(uMapping.getItems()));
                }
                if (rMapping != null) {
                    connector.sync(ObjectClass.GROUP, syncTask.getResource().getRsyncToken(), handler,
                            connector.getOperationOptions(rMapping.getItems()));
                }
            }

            if (!dryRun && !syncTask.isFullReconciliation()) {
                try {
                    ExternalResource resource = resourceDAO.find(syncTask.getResource().getName());
                    if (uMapping != null) {
                        resource.setUsyncToken(latestUSyncToken);
                    }
                    if (rMapping != null) {
                        resource.setRsyncToken(latestRSyncToken);
                    }
                    resourceDAO.save(resource);
                } catch (Exception e) {
                    throw new JobExecutionException("While updating SyncToken", e);
                }
            }
        } catch (Exception e) {
            throw new JobExecutionException("While syncing on connector", e);
        }

        try {
            setRoleOwners(handler);
        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.quartz.JobExecutionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.