jeecgboot/JeecgBoot · error · JeecgBootException

${e.getMessage()}

Error message

${e.getMessage()}

What it means

Thrown by schedulerAdd in the catch(RuntimeException) branch, propagating e.getMessage() verbatim as a JeecgBootException with the original exception chained. This branch sits between SchedulerException and the generic Exception catch, so it captures non-Quartz runtime errors - most notably the ClassNotFoundException or ClassCastException from getClass(jobClassName) when the configured job class is missing or does not implement Job. Note the message is dynamic (${e.getMessage()}), so it surfaces the underlying runtime failure text directly.

Source

Thrown at jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/QuartzJobServiceImpl.java:155

	private void schedulerAdd(String id, String jobClassName, String cronExpression, String parameter) {
		try {
			// 启动调度器
			scheduler.start();

			// 构建job信息
			JobDetail jobDetail = JobBuilder.newJob(getClass(jobClassName).getClass()).withIdentity(id).usingJobData("parameter", parameter).build();

			// 表达式调度构建器(即任务执行的时间)
			CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);

			// 按新的cronExpression表达式构建一个新的trigger
			CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(id).withSchedule(scheduleBuilder).build();

			scheduler.scheduleJob(jobDetail, trigger);
		} catch (SchedulerException e) {
			throw new JeecgBootException("创建定时任务失败", e);
		} catch (RuntimeException e) {
			throw new JeecgBootException(e.getMessage(), e);
		}catch (Exception e) {
			throw new JeecgBootException("后台找不到该类名:" + jobClassName, e);
		}
	}

	/**
	 * 删除定时任务
	 * 
	 * @param id
	 */
	private void schedulerDelete(String id) {
		try {
			scheduler.pauseTrigger(TriggerKey.triggerKey(id));
			scheduler.unscheduleJob(TriggerKey.triggerKey(id));
			scheduler.deleteJob(JobKey.jobKey(id));
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			throw new JeecgBootException("删除定时任务失败");

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Read the wrapped message text - it usually states the exact missing class or the 'must implement Job' violation.
  2. Ensure the job class exists on the runtime classpath under the org.jeecg.* package and implements org.quartz.Job.
  3. If the class was moved, update the jobClassName in the QRTZ/sys_quartz_job record to the new FQN.
  4. Rebuild/redeploy so the module containing the job class is on the classpath.

Example fix

// before: jobClassName = "com.oldpkg.MyTask"  (not on classpath / not in org.jeecg.*)
// after:  // move/recreate the class as org.jeecg.modules.quartz.job.MyJob implements Job
//         jobClassName = "org.jeecg.modules.quartz.job.MyJob"
Defensive patterns

Strategy: validation

Validate before calling

// Validate the job class before scheduling
private static boolean isSchedulableJobClass(String fqn) {
    try {
        Class<?> c = Class.forName(fqn);
        return c.getName().startsWith("org.jeecg.") && org.quartz.Job.class.isAssignableFrom(c);
    } catch (ClassNotFoundException e) {
        return false;
    }
}
if (!isSchedulableJobClass(jobClassName)) { /* reject before schedulerAdd */ }

Type guard

private static boolean isQuartzJobClass(String fqn) {
    try {
        Class<?> c = Class.forName(fqn);
        return org.quartz.Job.class.isAssignableFrom(c)
            && c.getName().startsWith("org.jeecg.");
    } catch (Throwable t) {
        return false;
    }
}

Try / catch

try {
    quartzJobService.saveAndSchedule(job);
} catch (JeecgBootException e) {
    // message is dynamic (e.getMessage()); if it names a missing class or 'must implement Job',
    // fix the jobClassName / classpath rather than retrying
}

Prevention

When it happens

Trigger: jobClassName refers to a class not on the classpath; the class exists but does not implement org.quartz.Job; the class is in a package blocked by the safe-load guard (getClass restricts to org.jeecg.*); a NoSuchMethodException/IllegalAccessException during instantiation.

Common situations: Deploying a job whose implementing class was removed/renamed; referencing a class in a non-jeecg package; the class is present but in a module not loaded (microservice split); version upgrade moved the class.

Related errors


AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14). Data as JSON: /api/errors/e51546ba7ac4a0d1. Report an issue: GitHub.