quarkusio/quarkus · error · NoSuchElementException
Could not expand value %s in property %s
Error message
Could not expand value %s in property %s
What it means
When expanding property placeholders inside @Scheduled schedule expressions, SchedulerUtils installs a SmallRye Config interceptor that resolves each referenced property. If the property cannot be resolved from config and has no default value, expansion fails with this NoSuchElementException naming the property key and expression.
Source
Thrown at extensions/scheduler/common/src/main/java/io/quarkus/scheduler/common/runtime/util/SchedulerUtils.java:161
return val;
}
/**
* Adapted from {@link io.smallrye.config.ExpressionConfigSourceInterceptor}
*/
private static String resolvePropertyExpression(String expr) {
final Config config = ConfigProvider.getConfig();
final Expression expression = Expression.compile(expr, LENIENT_SYNTAX, NO_TRIM);
final String expanded = expression.evaluate(new BiConsumer<ResolveContext<RuntimeException>, StringBuilder>() {
@Override
public void accept(ResolveContext<RuntimeException> resolveContext, StringBuilder stringBuilder) {
final Optional<String> resolve = config.getOptionalValue(resolveContext.getKey(), String.class);
if (resolve.isPresent()) {
stringBuilder.append(resolve.get());
} else if (resolveContext.hasDefault()) {
resolveContext.expandDefault();
} else {
throw new NoSuchElementException(String.format("Could not expand value %s in property %s",
resolveContext.getKey(), expr));
}
}
});
return expanded;
}
private static boolean isConfigExpression(String val) {
if (val == null) {
return false;
}
int exprStart = val.indexOf("${");
int exprEnd = -1;
if (exprStart >= 0) {
exprEnd = val.indexOf('}', exprStart + 2);
}
return exprEnd > 0;
}View on GitHub (pinned to e1c734241f)
Solutions
- Define the missing property in application.properties or via an environment variable
- Provide an inline default in the expression, e.g. ${my.cron:0 0 * * * ?}
- Check the active Quarkus profile — the property may exist only under another profile
- Search for the exact key referenced by the schedule expression and fix typos
Example fix
// before
@Scheduled(cron = "{app.cron}")
// after (with default)
@Scheduled(cron = "{app.cron:0/30 * * * * ?}")
// or add to application.properties:
// app.cron=0/30 * * * * ? Defensive patterns
Strategy: validation
Validate before calling
Optional<String> v = ConfigProvider.getConfig().getOptionalValue("app.cron", String.class);
if (v.isEmpty()) throw new IllegalStateException("app.cron must be set for the schedule"); Try / catch
try { String cron = config.getValue("app.cron", String.class); }
catch (NoSuchElementException e) { /* supply default or fail fast with clear message */ } Prevention
- Provide defaults in property expressions: ${key:defaultValue}
- Set required properties for every active Quarkus profile
- Validate config at startup with @ConfigMapping and mandatory keys
- Keep property names consistent between code and application.properties
When it happens
Trigger: A @Scheduled attribute (cron/every/delayed) references a config property (e.g. ${my.cron}) that is not present in application.properties / env / config sources and has no default.
Common situations: Typo in the property name; property defined only in another profile (e.g. %prod) while running in dev; property removed after a version upgrade; forgetting to set the env var that backs the property.
Related errors
- Invalid () expression on:
- Either the 'cron' expression or the 'every' period must be s
- The class (${name}) cannot be created during deployment.
- Can not add converter ${converter.name()} that is not parame
- Converter ${converter.name()} must be parameterized with a s
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/0f15751a79225962.
Report an issue: GitHub.