quarkusio/quarkus · error · IllegalArgumentException
Invalid @Scheduled method '<method>': 'initialDelay' not sup
Error message
Invalid @Scheduled method '<method>': 'initialDelay' not supported for cron triggers
What it means
Cron-based Spring @Scheduled triggers do not take an initial delay, so combining cron with initialDelay/initialDelayString is contradictory. The Quarkus spring-scheduled processor rejects this combination at build time.
Source
Thrown at extensions/spring-scheduled/deployment/src/main/java/io/quarkus/spring/scheduled/deployment/SpringScheduledProcessor.java:107
List<AnnotationValue> springAnnotationValues = scheduledAnnotation.values();
List<AnnotationValue> confValues = new ArrayList<>();
if (!springAnnotationValues.isEmpty()) {
if (annotationsValuesContain(springAnnotationValues, "fixedRate")
|| annotationsValuesContain(springAnnotationValues, "fixedRateString")) {
confValues.add(buildEveryParam(springAnnotationValues));
if (annotationsValuesContain(springAnnotationValues, "initialDelay")
|| annotationsValuesContain(springAnnotationValues, "initialDelayString")) {
confValues.addAll(buildDelayParams(springAnnotationValues));
}
} else if (annotationsValuesContain(springAnnotationValues, "fixedDelay")
|| annotationsValuesContain(springAnnotationValues, "fixedDelayString")) {
throw new IllegalArgumentException(
"Invalid @Scheduled method '" + method.name()
+ "': 'fixedDelay' not supported");
} else if (annotationsValuesContain(springAnnotationValues, "cron")) {
if (annotationsValuesContain(springAnnotationValues, "initialDelay")) {
throw new IllegalArgumentException(
"Invalid @Scheduled method '" + method.name()
+ "': 'initialDelay' not supported for cron triggers");
}
confValues.add(buildCronParam(springAnnotationValues));
}
}
AnnotationInstance regularAnnotationInstance = AnnotationInstance.create(QUARKUS_SCHEDULED,
scheduledAnnotation.target(), confValues);
schedules.add(regularAnnotationInstance);
}
if (schedules != null) {
scheduledBusinessMethods.produce(new ScheduledBusinessMethodItem(bean, method, schedules));
LOGGER.debugf("Found scheduled business method %s declared on %s", method, bean);
}
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Remove initialDelay/initialDelayString from the cron-based @Scheduled
- Adjust the cron expression so the first fire time is delayed
- Implement startup-delay logic in the method body or via a delayed startup bean
Example fix
// before
@Scheduled(cron = "0 0 * * * *", initialDelay = 30000)
void report() {}
// after
@Scheduled(cron = "0 0 * * * *")
void report() {} Defensive patterns
Strategy: validation
Validate before calling
Scheduled s = method.getAnnotation(Scheduled.class);
if (s != null && !s.cron().isEmpty() && (s.initialDelay() > 0 || !s.initialDelayString().isEmpty())) {
throw new IllegalStateException("initialDelay invalid with cron on " + method.getName());
} Prevention
- Never mix cron with initialDelay attributes
- Encode the desired first-fire time in the cron expression
- Validate @Scheduled attribute combinations in a unit test
When it happens
Trigger: @Scheduled(cron = "0 0 * * * *", initialDelay = 30000) or cron combined with initialDelayString on the same method, processed by the spring-scheduled extension.
Common situations: Migrating Spring jobs where developers added initialDelay to a cron schedule expecting a startup grace period; copy-pasted attributes across schedule styles.
Related errors
- Invalid @Scheduled method '<method>': 'fixedDelay' not suppo
- Invalid '<paramName>String' value "<value>" - cannot parse i
- Failed to open path tree with root %s
- Dev services for ${request.getName()} requires a startable s
- Name cannot start with '/':${name}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/dea99fd58b82a448.
Report an issue: GitHub.