quarkusio/quarkus · error · IllegalStateException

Quartz scheduler is either explicitly disabled through quark

Error message

Quartz scheduler is either explicitly disabled through quarkus.scheduler.enabled=false or no @Scheduled methods were found. If you only need to schedule a job programmatically you can force the start of the scheduler by setting 'quarkus.scheduler.start-mode=forced'.

What it means

produceQuartzScheduler is a CDI @Produces method for org.quartz.Scheduler. If the scheduler was never started — because quarkus.scheduler.enabled=false or the application contains no @Scheduled methods — the producer throws IllegalStateException explaining the situation and suggesting quarkus.scheduler.start-mode=forced.

Source

Thrown at extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzSchedulerImpl.java:324

                }
            } catch (Throwable e) {
                if (transaction != null) {
                    try {
                        transaction.rollback();
                    } catch (SystemException ex) {
                        LOGGER.error("Unable to rollback transaction", ex);
                    }
                }
                throw new IllegalStateException("Unable to create Scheduler", e);
            }
        }
    }

    @Produces
    @Singleton
    org.quartz.Scheduler produceQuartzScheduler() {
        if (scheduler == null) {
            throw new IllegalStateException(
                    "Quartz scheduler is either explicitly disabled through quarkus.scheduler.enabled=false or no @Scheduled methods were found. If you only need to schedule a job programmatically you can force the start of the scheduler by setting 'quarkus.scheduler.start-mode=forced'.");
        }
        return scheduler;
    }

    @Override
    public org.quartz.Scheduler getScheduler() {
        return scheduler;
    }

    @Override
    public boolean isStarted() {
        return scheduler != null;
    }

    @Override
    public String implementation() {
        return Scheduled.QUARTZ;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Set quarkus.scheduler.start-mode=forced to start the scheduler even without @Scheduled methods.
  2. Remove quarkus.scheduler.enabled=false (or set it to true) if you actually want the scheduler.
  3. Ensure at least one @Scheduled method exists, or schedule programmatically only after forcing startup.
  4. Guard injection so the Scheduler is only requested when it's expected to be running.

Example fix

# before
quarkus.scheduler.enabled=false
// injecting org.quartz.Scheduler fails

# after
quarkus.scheduler.start-mode=forced
Defensive patterns

Strategy: validation

Validate before calling

boolean enabled = ConfigProvider.getConfig().getOptionalValue("quarkus.scheduler.enabled", Boolean.class).orElse(true);
String startMode = ConfigProvider.getConfig().getOptionalValue("quarkus.scheduler.start-mode", String.class).orElse("normal");
boolean hasScheduledMethods = /* true if app declares @Scheduled */ false;
if (!enabled || (!hasScheduledMethods && !"forced".equals(startMode))) {
    log.warn("Scheduler not started; org.quartz.Scheduler injection will fail");
}

Try / catch

try {
    Scheduler s = CDI.current().select(org.quartz.Scheduler.class).get();
} catch (IllegalStateException e) {
    if (e.getMessage().contains("quarkus.scheduler.enabled=false")) {
        // scheduler intentionally off: fall back to a no-op scheduling path
        return;
    }
    throw e;
}

Prevention

When it happens

Trigger: Inject org.quartz.Scheduler (or get it via CDI) when the scheduler is disabled via quarkus.scheduler.enabled=false, or when no @Scheduled methods exist so the lazy scheduler was never created and start-mode is not 'forced'.

Common situations: Injecting the Scheduler to schedule jobs programmatically in an app with no annotated @Scheduled methods; QA/test config disabling the scheduler; app assembled from reusable modules without scheduled methods.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/67916fbeefa3174e. Report an issue: GitHub.