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

  1. Define the missing property in application.properties or via an environment variable
  2. Provide an inline default in the expression, e.g. ${my.cron:0 0 * * * ?}
  3. Check the active Quarkus profile — the property may exist only under another profile
  4. 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

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


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