Search in sources :

Example 11 with JobExecutionException

use of org.quartz.JobExecutionException in project OpenClinica by OpenClinica.

the class ImportSpringJob method executeInternal.

@Override
protected void executeInternal(final JobExecutionContext context) throws JobExecutionException {
    ApplicationContext appContext;
    try {
        appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
        TransactionTemplate transactionTemplate = (TransactionTemplate) appContext.getBean("sharedTransactionTemplate");
        transactionTemplate.execute(new TransactionCallbackWithoutResult() {

            @Override
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                executeInternalInTransaction(context);
            }
        });
    } catch (SchedulerException e) {
        throw new JobExecutionException(e);
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) SchedulerException(org.quartz.SchedulerException) JobExecutionException(org.quartz.JobExecutionException) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult)

Example 12 with JobExecutionException

use of org.quartz.JobExecutionException in project sling by apache.

the class QuartzJobExecutor method execute.

/**
     * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
     */
@Override
public void execute(final JobExecutionContext context) throws JobExecutionException {
    final JobDataMap data = context.getJobDetail().getJobDataMap();
    final JobDesc desc = new JobDesc(data);
    final Logger logger = (Logger) data.get(QuartzScheduler.DATA_MAP_LOGGER);
    // check run on information
    if (!shouldRun(logger, desc)) {
        return;
    }
    String origThreadName = Thread.currentThread().getName();
    try {
        Thread.currentThread().setName(origThreadName + "-" + desc.name);
        logger.debug("Executing job {}", desc);
        if (desc.job instanceof org.apache.sling.commons.scheduler.Job) {
            @SuppressWarnings("unchecked") final Map<String, Serializable> configuration = (Map<String, Serializable>) data.get(QuartzScheduler.DATA_MAP_CONFIGURATION);
            final JobContext jobCtx = new JobContextImpl(desc.name, configuration);
            ((org.apache.sling.commons.scheduler.Job) desc.job).execute(jobCtx);
        } else if (desc.job instanceof Runnable) {
            ((Runnable) desc.job).run();
        } else {
            logger.error("Scheduled job {} is neither a job nor a runnable: {}", desc);
        }
    } catch (final Throwable t) {
        // if this is a quartz exception, rethrow it
        if (t instanceof JobExecutionException) {
            throw (JobExecutionException) t;
        }
        // there is nothing we can do here, so we just log
        logger.error("Exception during job execution of " + desc + " : " + t.getMessage(), t);
    } finally {
        Thread.currentThread().setName(origThreadName);
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) Serializable(java.io.Serializable) Logger(org.slf4j.Logger) JobExecutionException(org.quartz.JobExecutionException) JobContext(org.apache.sling.commons.scheduler.JobContext) Job(org.quartz.Job) JobDataMap(org.quartz.JobDataMap) Map(java.util.Map)

Example 13 with JobExecutionException

use of org.quartz.JobExecutionException in project oxCore by GluuFederation.

the class TimerJob method execute.

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    try {
        TimerEvent timerEvent = (TimerEvent) context.getJobDetail().getJobDataMap().get(KEY_TIMER_EVENT);
        if (timerEvent == null) {
            return;
        }
        log.debug("Fire timer event [{}] with qualifiers {}", timerEvent.getTargetEvent().getClass().getName(), timerEvent.getQualifiers());
        beanManager.fireEvent(timerEvent.getTargetEvent(), timerEvent.getQualifiers());
    } catch (Exception ex) {
        throw new JobExecutionException(ex);
    }
}
Also used : JobExecutionException(org.quartz.JobExecutionException) TimerEvent(org.xdi.service.timer.event.TimerEvent) JobExecutionException(org.quartz.JobExecutionException)

Example 14 with JobExecutionException

use of org.quartz.JobExecutionException in project bamboobsc by billchen198318.

the class ClearTempDataJobImpl method executeInternal.

@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
    if (ContextLoader.getCurrentWebApplicationContext() == null) {
        log.warn("ApplicationContext no completed, AppContext.getApplicationContext() == null");
        return;
    }
    log.info("begin....");
    try {
        /**
			 * document reference:
			 * com.netsteadfast.greenstep.support.CleanTempUploadForContextInitAndDestroy.java
			 */
        this.loginForBackgroundProgram();
        List<SysVO> systems = ApplicationSiteUtils.getSystems();
        if (systems == null || systems.size() < 1) {
            return;
        }
        for (SysVO sys : systems) {
            UploadSupportUtils.cleanTempUpload(sys.getSysId());
        }
        /**
			 * document reference:
			 * com.netsteadfast.greenstep.bsc.support.CleanJasperReportTempDataForContextInitAndDestroy.java
			 * 
			 */
        NamedParameterJdbcTemplate namedParameterJdbcTemplate = (NamedParameterJdbcTemplate) AppContext.getBean("namedParameterJdbcTemplate");
        Map<String, Object> paramMap = new HashMap<String, Object>();
        namedParameterJdbcTemplate.update("delete from bb_swot_report_mst", paramMap);
        namedParameterJdbcTemplate.update("delete from bb_swot_report_dtl", paramMap);
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            this.logoutForBackgroundProgram();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    log.info("end....");
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) HashMap(java.util.HashMap) SysVO(com.netsteadfast.greenstep.vo.SysVO) JobExecutionException(org.quartz.JobExecutionException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Example 15 with JobExecutionException

use of org.quartz.JobExecutionException in project engine by craftercms.

the class ScriptJob method execute.

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    JobDataMap dataMap = context.getJobDetail().getJobDataMap();
    String scriptUrl = dataMap.getString(SCRIPT_URL_DATA_KEY);
    SiteContext siteContext = (SiteContext) dataMap.get(SITE_CONTEXT_DATA_KEY);
    ServletContext servletContext = (ServletContext) dataMap.get(SERVLET_CONTEXT_DATA_KEY);
    ScriptFactory scriptFactory = siteContext.getScriptFactory();
    if (scriptFactory == null) {
        throw new JobExecutionException("No script factory associate to site context '" + siteContext.getSiteName() + "'");
    }
    SiteContext.setCurrent(siteContext);
    try {
        Map<String, Object> variables = new HashMap<>();
        GroovyScriptUtils.addJobScriptVariables(variables, servletContext);
        scriptFactory.getScript(scriptUrl).execute(variables);
    } catch (Exception e) {
        throw new JobExecutionException("Error executing script job at " + scriptUrl, e);
    } finally {
        SiteContext.clear();
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) JobExecutionException(org.quartz.JobExecutionException) HashMap(java.util.HashMap) SiteContext(org.craftercms.engine.service.context.SiteContext) ServletContext(javax.servlet.ServletContext) ScriptFactory(org.craftercms.engine.scripting.ScriptFactory) JobExecutionException(org.quartz.JobExecutionException)

Aggregations

JobExecutionException (org.quartz.JobExecutionException)33 SchedulerException (org.quartz.SchedulerException)9 EmailException (org.apache.commons.mail.EmailException)6 JobDataMap (org.quartz.JobDataMap)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 SchedulerContext (org.quartz.SchedulerContext)4 TimeSeriesResponse (com.linkedin.thirdeye.client.timeseries.TimeSeriesResponse)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ExecutionException (java.util.concurrent.ExecutionException)3 CamelContext (org.apache.camel.CamelContext)3 Route (org.apache.camel.Route)3 HtmlEmail (org.apache.commons.mail.HtmlEmail)3 ThirdEyeAnomalyConfiguration (com.linkedin.thirdeye.anomaly.ThirdEyeAnomalyConfiguration)2 MetricDimensionReport (com.linkedin.thirdeye.anomaly.alert.template.pojo.MetricDimensionReport)2 DataReportHelper (com.linkedin.thirdeye.anomaly.alert.util.DataReportHelper)2 DimensionKey (com.linkedin.thirdeye.api.DimensionKey)2 MetricTimeSeries (com.linkedin.thirdeye.api.MetricTimeSeries)2 TimeGranularity (com.linkedin.thirdeye.api.TimeGranularity)2 MetricExpression (com.linkedin.thirdeye.client.MetricExpression)2