quarkusio/quarkus · error · IllegalStateException
Cannot call getValue() at deployment time
Error message
Cannot call getValue() at deployment time
What it means
RuntimeValue.getValue() throws IllegalStateException when the wrapped value is null, which for a recorder-created RuntimeValue means the underlying runtime object has not been created yet — i.e. the method is being invoked at deployment time instead of at runtime. Recorder code must only call getValue() inside recorded bytecode that executes at runtime.
Source
Thrown at core/runtime/src/main/java/io/quarkus/runtime/RuntimeValue.java:25
* and passed between recorders.
*
*/
public class RuntimeValue<T> {
private final T value;
public RuntimeValue(T value) {
Objects.requireNonNull(value);
this.value = value;
}
public RuntimeValue() {
this.value = null;
}
public T getValue() {
if (value == null) {
throw new IllegalStateException("Cannot call getValue() at deployment time");
}
return value;
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Move the getValue() call into code that is recorded (RecordedFunction/bytecode) so it executes at runtime.
- Do not construct new RuntimeValue() manually; return values from recorder methods so the value is set.
- At deployment time, operate on the RuntimeValue handle, not its contents.
- If you need the value during the build, use a different build item mechanism rather than getValue().
Example fix
// before (recorder, deployment time) var svc = runtimeValue.getValue(); serviceConfig.call(svc); // after serviceConfig.call(runtimeValue, "getValue"); // record the call for runtime
Defensive patterns
Strategy: validation
Validate before calling
// in recorder/deployment code, never call getValue(); assert you are recording instead: // bad: runtimeValue.getValue(); good: pass runtimeValue to recorded invocations
Type guard
boolean safeToRead(RuntimeValue<?> rv) { return rv != null && isRuntimePhase(); } // isRuntimePhase(): true only in runtime-init/recorded code Try / catch
try { return runtimeValue.getValue(); } catch (IllegalStateException e) { throw new IllegalStateException("called getValue() at deployment time; move to recorded runtime code", e); } Prevention
- Never call getValue() inside @Recorder methods or build steps
- Let recorder methods return RuntimeValue instead of constructing new RuntimeValue() manually
- Operate on the handle during the build; dereference only at runtime
When it happens
Trigger: Calling runtimeValue.getValue() directly inside a @Recorder method or build step at deployment time; reading the value before the recording produced the target object.
Common situations: Extension authors writing recorders who accidentally dereference the RuntimeValue during build; passing a no-arg-constructed RuntimeValue (new RuntimeValue()) and reading it immediately.
Related errors
- Failed to record call to method ${call.method}
- All parameters have already been loaded, it is too late to c
- String too large to record: ${param}
- Unsupported wildcard type: ${wildcard}
- Failed to open path tree with root %s
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/9ee264cc6d831147.
Report an issue: GitHub.