quarkusio/quarkus · error · IllegalStateException
runtime config has already been set
Error message
runtime config has already been set
What it means
Deployment.setRuntimeConfiguration is idempotent-by-first-write: once a RuntimeConfiguration has been installed on a Deployment, calling setRuntimeConfiguration again throws this IllegalStateException. The deployment refuses to swap runtime configuration after it has been set, to keep configuration consistent for the live application.
Source
Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/Deployment.java:209
public ThreadSetupAction getThreadSetupAction() {
return threadSetupAction;
}
public RequestContextFactory getRequestContextFactory() {
return requestContextFactory;
}
public List<GenericRuntimeConfigurableServerRestHandler<?>> getRuntimeConfigurableServerRestHandlers() {
return runtimeConfigurableServerRestHandlers;
}
public RuntimeConfiguration getRuntimeConfiguration() {
return runtimeConfiguration;
}
public Deployment setRuntimeConfiguration(RuntimeConfiguration runtimeConfiguration) {
if (this.runtimeConfiguration != null) {
throw new IllegalStateException("runtime config has already been set");
}
this.runtimeConfiguration = runtimeConfiguration;
return this;
}
public Map<String, List<String>> getDisabledEndpoints() {
return disabledEndpoints;
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Call setRuntimeConfiguration exactly once per Deployment instance; create a new Deployment if configuration must change.
- Guard your bootstrap code with an 'initialized' flag or check deployment.getRuntimeConfiguration() != null before setting.
- In tests, rebuild the Deployment object for each test rather than reusing and reconfiguring a shared instance.
Example fix
// before
deployment.setRuntimeConfiguration(cfg); // called twice in restart path
// after
if (deployment.getRuntimeConfiguration() == null) {
deployment.setRuntimeConfiguration(cfg);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (deployment.getRuntimeConfiguration() != null) {
// skip re-setting, or replace the whole Deployment
} else {
deployment.setRuntimeConfiguration(runtimeConfig);
} Try / catch
try {
deployment.setRuntimeConfiguration(cfg);
} catch (IllegalStateException e) {
if ("runtime config has already been set".equals(e.getMessage())) {
log.warn("Runtime configuration already set; reusing existing configuration");
} else {
throw e;
}
} Prevention
- Initialize the Deployment in a single well-defined bootstrap method.
- Make bootstrap idempotent with an initialization guard flag.
- In tests, construct a new Deployment per test lifecycle phase.
- Audit dev-mode/restart code paths for repeated calls into setup methods.
When it happens
Trigger: Calling createApplication-style bootstrapping code that invokes deployment.setRuntimeConfiguration(cfg) more than once on the same Deployment instance — e.g. a custom bootstrap, dev-mode restart path, or test harness that re-sets config.
Common situations: Custom embedding of RESTEasy Reactive (not via Quarkus) where the setup code is accidentally executed twice; test frameworks building the Deployment in @BeforeEach without recreating the Deployment object; double initialization after a runtime reload.
Related errors
- Handler '${handlerClassName}' has not been properly configur
- Setting both 'readBody' and 'preMatching' to 'true' on '@Ser
- Setting both '@WithFormRead' and 'preMatching' to 'true' on
- Could not load exception mapper
- Failed to load application configuration
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/a3137b1e1cc31ce4.
Report an issue: GitHub.