{"record":{"id":"dea99fd58b82a448","repo":"quarkusio/quarkus","slug":"invalid-scheduled-method-method-initialdela","errorCode":null,"errorMessage":"Invalid @Scheduled method '<method>': 'initialDelay' not supported for cron triggers","messagePattern":"Invalid @Scheduled method '<method>': 'initialDelay' not supported for cron triggers","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/spring-scheduled/deployment/src/main/java/io/quarkus/spring/scheduled/deployment/SpringScheduledProcessor.java","lineNumber":107,"sourceCode":"                List<AnnotationValue> springAnnotationValues = scheduledAnnotation.values();\n                List<AnnotationValue> confValues = new ArrayList<>();\n                if (!springAnnotationValues.isEmpty()) {\n                    if (annotationsValuesContain(springAnnotationValues, \"fixedRate\")\n                            || annotationsValuesContain(springAnnotationValues, \"fixedRateString\")) {\n                        confValues.add(buildEveryParam(springAnnotationValues));\n                        if (annotationsValuesContain(springAnnotationValues, \"initialDelay\")\n                                || annotationsValuesContain(springAnnotationValues, \"initialDelayString\")) {\n                            confValues.addAll(buildDelayParams(springAnnotationValues));\n                        }\n\n                    } else if (annotationsValuesContain(springAnnotationValues, \"fixedDelay\")\n                            || annotationsValuesContain(springAnnotationValues, \"fixedDelayString\")) {\n                        throw new IllegalArgumentException(\n                                \"Invalid @Scheduled method '\" + method.name()\n                                        + \"': 'fixedDelay' not supported\");\n                    } else if (annotationsValuesContain(springAnnotationValues, \"cron\")) {\n                        if (annotationsValuesContain(springAnnotationValues, \"initialDelay\")) {\n                            throw new IllegalArgumentException(\n                                    \"Invalid @Scheduled method '\" + method.name()\n                                            + \"': 'initialDelay' not supported for cron triggers\");\n                        }\n                        confValues.add(buildCronParam(springAnnotationValues));\n                    }\n\n                }\n                AnnotationInstance regularAnnotationInstance = AnnotationInstance.create(QUARKUS_SCHEDULED,\n                        scheduledAnnotation.target(), confValues);\n                schedules.add(regularAnnotationInstance);\n            }\n            if (schedules != null) {\n                scheduledBusinessMethods.produce(new ScheduledBusinessMethodItem(bean, method, schedules));\n                LOGGER.debugf(\"Found scheduled business method %s declared on %s\", method, bean);\n            }\n        }\n    }\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-scheduled/deployment/src/main/java/io/quarkus/spring/scheduled/deployment/SpringScheduledProcessor.java#L89-L125","documentation":"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.","triggerScenarios":"@Scheduled(cron = \"0 0 * * * *\", initialDelay = 30000) or cron combined with initialDelayString on the same method, processed by the spring-scheduled extension.","commonSituations":"Migrating Spring jobs where developers added initialDelay to a cron schedule expecting a startup grace period; copy-pasted attributes across schedule styles.","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"],"exampleFix":"// before\n@Scheduled(cron = \"0 0 * * * *\", initialDelay = 30000)\nvoid report() {}\n\n// after\n@Scheduled(cron = \"0 0 * * * *\")\nvoid report() {}","handlingStrategy":"validation","validationCode":"Scheduled s = method.getAnnotation(Scheduled.class);\nif (s != null && !s.cron().isEmpty() && (s.initialDelay() > 0 || !s.initialDelayString().isEmpty())) {\n    throw new IllegalStateException(\"initialDelay invalid with cron on \" + method.getName());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never mix cron with initialDelay attributes","Encode the desired first-fire time in the cron expression","Validate @Scheduled attribute combinations in a unit test"],"tags":["spring-scheduled","cron","initialdelay","build-time","quarkus"],"backgroundTag":"initialdelay-cron-conflict","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}