quarkusio/quarkus · error · IllegalStateException

A job with this identity is already scheduled: ${identity}

Error message

A job with this identity is already scheduled: ${identity}

What it means

Quarkus throws this IllegalStateException from Scheduler.newJob(identity) when a job (programmatic scheduled task) with the given identity is already registered in the scheduler's task map. Identities must be unique; this guard prevents silently overwriting an existing QuartzJobDefinition.

Source

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

    public Trigger getScheduledJob(String identity) {
        if (!isStarted()) {
            throw notStarted();
        }
        Objects.requireNonNull(identity);
        if (identity.isEmpty()) {
            return null;
        }
        return scheduledTasks.get(SchedulerUtils.lookUpPropertyValue(identity));
    }

    @Override
    public QuartzJobDefinition newJob(String identity) {
        if (!isStarted()) {
            throw notStarted();
        }
        Objects.requireNonNull(identity);
        if (scheduledTasks.containsKey(identity)) {
            throw new IllegalStateException("A job with this identity is already scheduled: " + identity);
        }
        return new QuartzJobDefinitionImpl(identity);
    }

    @Override
    public Trigger unscheduleJob(String identity) {
        if (!isStarted()) {
            throw notStarted();
        }
        Objects.requireNonNull(identity);
        if (!identity.isEmpty()) {
            String parsedIdentity = SchedulerUtils.lookUpPropertyValue(identity);
            QuartzTrigger trigger = scheduledTasks.get(parsedIdentity);
            if (trigger != null && trigger.isProgrammatic) {
                if (scheduledTasks.remove(identity) != null) {
                    try {
                        scheduler.unscheduleJob(trigger.triggerKey);
                    } catch (SchedulerException e) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pick a unique identity per job instance (e.g. append a UUID or business key)
  2. Check Scheduler.getScheduledJob(identity) for null before calling newJob()
  3. Call Scheduler.unscheduleJob(identity) to remove the existing programmatic job first
  4. Avoid reusing identities of static @Scheduled methods

Example fix

// before
scheduler.newJob("report"); // IllegalStateException on retry
// after
if (scheduler.getScheduledJob("report") == null) {
    scheduler.newJob("report");
} else {
    scheduler.unscheduleJob("report");
    scheduler.newJob("report");
}
Defensive patterns

Strategy: validation

Validate before calling

if (scheduler.getScheduledJob(identity) != null) {
    throw new IllegalArgumentException("identity already used: " + identity);
}

Try / catch

try {
    scheduler.newJob(identity);
} catch (IllegalStateException e) {
    // identity taken — regenerate or unschedule first
    scheduler.unscheduleJob(identity);
    scheduler.newJob(identity + "-" + UUID.randomUUID());
}

Prevention

When it happens

Trigger: Calling Scheduler.newJob("myJob") twice with the same identity without unscheduling the first; identity collides with a statically declared @Scheduled job's identity; a previous programmatic job was never removed via unscheduleJob().

Common situations: Generating job identities without uniqueness (missing UUID/tenant suffix); re-registering on reconnect/redeploy logic; same identity reused across application restarts when tasks are kept in the JDBC store.

Related errors


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