quarkusio/quarkus · error · IllegalStateException
The application is stopping
Error message
The application is stopping
What it means
Application.start() synchronizes on a state lock and only proceeds when the application state allows starting; ST_STARTED returns immediately, but any other non-starting state (i.e. the application is shutting down or stopped) throws this IllegalStateException. It protects against starting work on an application instance whose lifecycle is winding down, typically during shutdown races.
Source
Thrown at core/runtime/src/main/java/io/quarkus/runtime/Application.java:104
stateLock.lock();
try {
loop: for (;;)
switch (state) {
case ST_INITIAL:
break loop; // normal startup
case ST_STARTING: {
try {
stateCond.await();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw interruptedOnAwaitStart();
}
break;
}
case ST_STARTED:
return; // all good
default: {
throw new IllegalStateException("The application is stopping");
}
}
state = ST_STARTING;
} finally {
stateLock.unlock();
}
try {
doStart(args);
} catch (Throwable t) {
stateLock.lock();
final ConfigProviderResolver cpr = ConfigProviderResolver.instance();
try {
cpr.releaseConfig(cpr.getConfig());
} catch (IllegalStateException ignored) {
// just means no config was installed, which is fine
}
try {
state = ST_STOPPED;View on GitHub (pinned to e1c734241f)
Solutions
- Inspect why the application was stopping: check logs for a concurrent shutdown (shutdown hook, SIGTERM, another stop() call).
- Do not reuse a stopped Application instance; create a new instance and start that.
- Serialize lifecycle: ensure shutdown hooks and manual stop() are not invoked concurrently with start() in your code/tests.
- If triggered by the platform (container restart), treat it as expected behavior and let the new process boot a fresh instance.
Example fix
// before: reusing the stopped instance app.stop(); app.start(); // IllegalStateException: The application is stopping // after: new instance app = new Application(); ApplicationLifecycleManager.run(app, null, null, LaunchMode.NORMAL);
Defensive patterns
Strategy: try-catch
Validate before calling
// start only if not already shutting down
if (lifecycleManager.isShutdownRequested()) {
throw new IllegalStateException("Refusing to start during shutdown");
} Try / catch
try {
app.start();
} catch (IllegalStateException e) {
if ("The application is stopping".equals(e.getMessage())) {
log.warn("Start raced with shutdown; booting a fresh instance");
app = createAndStartNewApplication();
} else throw e;
} Prevention
- Never call start() from shutdown hooks or shutdown paths.
- Coordinate lifecycle calls with a single owner thread or executor.
- In containers, let the platform restart the process rather than restarting a stopped instance.
- In tests, use framework-managed lifecycle (@QuarkusTest) instead of manual start/stop.
When it happens
Trigger: Calling start() (directly or via run/QuarkusHttpFunction/QuarkusBackgroundFunction/QuarkusCloudEventsFunction) while another thread has moved the instance into the stopping/stopped state — e.g. a shutdown hook fired concurrently with startup.
Common situations: Container SIGTERM arriving while the app is still booting; tests that stop the app in a background thread and then try to start it again; framework callbacks racing with shutdown.
Related errors
- The application has not been started
- Persistence unit is closed
- Unable to destroy contextual instance of " + bean
- java.lang.InterruptedException (wrapped)
- All parameters have already been loaded, it is too late to c
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/4a2c825e098f52a1.
Report an issue: GitHub.