{"record":{"id":"6987e7cf603aecb2","repo":"quarkusio/quarkus","slug":"internal-error-an-attempt-was-made-to-start-an-ap","errorCode":null,"errorMessage":"Internal error: An attempt was made to start an application which had already been started and closed. The affected ClassLoader is ${runtimeClassLoader}","messagePattern":"Internal error: An attempt was made to start an application which had already been started and closed\\. The affected ClassLoader is (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/deployment/src/main/java/io/quarkus/runner/bootstrap/StartupActionImpl.java","lineNumber":378,"sourceCode":"\n        try {\n            Class<?> overrideConfigSourceClass = runtimeClassLoader\n                    .loadClass(\"io.quarkus.devservice.runtime.config.DevServicesOverrideConfigSource\");\n            overrideConfigSourceClass.getMethod(\"setConfig\", Map.class).invoke(null, startResult.overrideConfigs());\n        } catch (ClassNotFoundException e) {\n            // devservices runtime module not available\n        } catch (ReflectiveOperationException e) {\n            throw new RuntimeException(\"Failed to set dev services override config\", e);\n        }\n    }\n\n    /**\n     * Runs the application, and returns a handle that can be used to shut it down.\n     */\n    public RunningQuarkusApplication run(String... args) throws Exception {\n\n        if (runtimeClassLoader.isClosed()) {\n            throw new RuntimeException(\n                    \"Internal error: An attempt was made to start an application which had already been started and closed. The affected ClassLoader is \"\n                            + runtimeClassLoader);\n\n        }\n        // Start dev services that weren't started in the augmentation phase\n        ensureDevServicesStarted();\n        InitialConfigurator.DELAYED_HANDLER.buildTimeComplete();\n\n        //first we hack around class loading in the fork join pool\n        ForkJoinClassLoading.setForkJoinClassLoader(runtimeClassLoader);\n\n        //we have our class loaders\n        ClassLoader old = Thread.currentThread().getContextClassLoader();\n        try {\n            Thread.currentThread().setContextClassLoader(runtimeClassLoader);\n            // force init here\n            Class<?> appClass = Class.forName(applicationClassName, true, runtimeClassLoader);\n            Method start = appClass.getMethod(\"start\", String[].class);","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/runner/bootstrap/StartupActionImpl.java#L360-L396","documentation":"StartupActionImpl.run() starts the application using its runtime class loader. If that class loader has already been closed (application previously started and shut down), starting it again is impossible and the framework throws this internal-error RuntimeException naming the affected class loader.","triggerScenarios":"Calling run() (directly or via test hooks like beforeAll) on a StartupActionImpl whose runtime class loader was closed by a previous run/stop cycle — e.g. running an application twice, or a test lifecycle reusing a closed StartupAction.","commonSituations":"Re-running a completed QuarkusTest lifecycle; custom harnesses calling run() after stop()/close(); reusing a StartupAction across test classes.","solutions":["Create a fresh StartupAction via createInitialRuntimeApplication() and run() that instead of reusing the old one","Track application lifecycle: never call run() after the RunningQuarkusApplication was closed","In tests, use the framework's per-test-class lifecycle rather than manual run() calls","If this appears unexpectedly, check for double-invocation of run() in your bootstrap code"],"exampleFix":"// before\nstartupAction.run();\n...\nrunningApp.close();\nstartupAction.run(); // throws: closed classloader\n// after\nstartupAction.run();\n...\nrunningApp.close();\nStartupActionImpl fresh = augmentAction.createInitialRuntimeApplication();\nfresh.run();","handlingStrategy":"validation","validationCode":"// before run()\nif (startupAction.isClosed()) { startupAction = augmentAction.createInitialRuntimeApplication(); }\nstartupAction.run();","typeGuard":null,"tryCatchPattern":"try { action.run(); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().contains(\"already been started and closed\")) { /* create a fresh StartupAction */ } else { throw e; } }","preventionTips":["Treat RunningQuarkusApplication as one-shot: never re-run a closed StartupAction","Create a new StartupAction per run cycle","In tests, rely on framework lifecycle instead of manual run()/close()"],"tags":["quarkus","lifecycle","classloader"],"backgroundTag":"application-already-closed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}