quarkusio/quarkus · error · IllegalStateException
Can only be called at runtime
Error message
Can only be called at runtime
What it means
RawCommandLineArgumentsBuildItem.get() is overridden to always throw IllegalStateException because the raw command line is only meaningful at runtime; build-time consumers must not read it. This is a deliberate misuse guard.
Source
Thrown at core/deployment/src/main/java/io/quarkus/deployment/builditem/RawCommandLineArgumentsBuildItem.java:36
/**
* As this object directly implements ReturnedProxy it can be
* passed into bytecode recorders. The runtime value of the command line parameters
* are placed directly into the startup context under this key.
*/
@Override
public String __returned$proxy$key() {
return StartupContext.RAW_COMMAND_LINE_ARGS;
}
@Override
public boolean __static$$init() {
return true;
}
@Override
public String[] get() {
throw new IllegalStateException("Can only be called at runtime");
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Remove the get() call from build-time code; process raw args only at runtime
- Consume RuntimeConfigSetupCompleteBuildItem or other runtime-phase hooks if runtime access is needed
- Use a different build item that exposes build-time-visible information
Example fix
// before (build step) String[] args = rawCommandLineArgumentsBuildItem.get(); // after // read args at runtime via a runtime recordable/bean instead
Defensive patterns
Strategy: try-catch
Validate before calling
if (buildItem instanceof RawCommandLineArgumentsBuildItem && isBuildTime()) { /* do not call get() */ } Try / catch
try { args = item.get(); } catch (IllegalStateException e) { log.warn("Raw command line is runtime-only", e); args = new String[0]; } Prevention
- Never read RawCommandLineArgumentsBuildItem in @BuildStep code
- Handle command-line arguments at runtime via runtime APIs
- Check whether a build item is runtime-only before consuming its getters
When it happens
Trigger: Calling get() on a RawCommandLineArgumentsBuildItem instance during the deployment (build-time) phase, e.g. inside a @BuildStep consuming this build item.
Common situations: A build step tries to inspect the raw application command-line arguments to make build-time decisions, which Quarkus forbids since arguments only exist at launch time.
Related errors
- Dev services for ${request.getName()} requires a startable s
- @RegisterClientContextResolver is only supported on static m
- @RegisterClientContextResolver is only supported on static m
- No order set
- Template extension method declared on must be static:
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/6c82a1f160a3fc17.
Report an issue: GitHub.