{"record":{"id":"8854b3c5fc2a2ce0","repo":"quarkusio/quarkus","slug":"cannot-set-both-application-root-and-app-artifact","errorCode":null,"errorMessage":"Cannot set both application root and app artifact","messagePattern":"Cannot set both application root and app artifact","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/QuarkusBootstrap.java","lineNumber":484,"sourceCode":"        }\n\n        public Builder setDisableClasspathCache(boolean disableClasspathCache) {\n            this.disableClasspathCache = disableClasspathCache;\n            return this;\n        }\n\n        public Builder addParentFirstArtifact(ArtifactKey appArtifactKey) {\n            this.parentFirstArtifacts.add(appArtifactKey);\n            return this;\n        }\n\n        /**\n         * The app artifact. Note that if you want to use this as the basis of the application\n         * you must also explicitly set the application root to this artifacts paths.\n         */\n        public Builder setAppArtifact(ResolvedDependency appArtifact) {\n            if (applicationRoot != null) {\n                throw new IllegalStateException(\"Cannot set both application root and app artifact\");\n            }\n            this.appArtifact = appArtifact;\n            this.applicationRoot = PathList.from(appArtifact.getResolvedPaths());\n            if (appArtifact.getResolvedPaths().isSinglePath()) {\n                this.projectRoot = appArtifact.getResolvedPaths().getSinglePath();\n            }\n            return this;\n        }\n\n        public Builder setManagingProject(ArtifactCoords managingProject) {\n            this.managingProject = managingProject;\n            return this;\n        }\n\n        /**\n         * If the deployment should use an isolated (aka parent last) classloader.\n         * <p>\n         * For tests this is generally false, as we want to share the base class path so that the","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/QuarkusBootstrap.java#L466-L502","documentation":"QuarkusBootstrap.Builder.setAppArtifact throws this IllegalStateException when an application root was already set. The two settings are mutually exclusive because setAppArtifact derives applicationRoot (and projectRoot for single-path artifacts) from the artifact's resolved paths.","triggerScenarios":"Calling QuarkusBootstrap.builder().setApplicationRoot(paths).setAppArtifact(dep) — i.e. invoking setAppArtifact after setApplicationRoot on the same Builder.","commonSituations":"Test harnesses or launchers that pre-configure an application root from the project directory and then also attach a resolved dependency as the app artifact (e.g. when adapting between local-run and artifact-run modes).","solutions":["Drop the setApplicationRoot call and rely on setAppArtifact to derive the root from the artifact's resolved paths.","Or keep setApplicationRoot and do not call setAppArtifact.","Restructure the builder usage so the source of truth (artifact vs. directory) is decided once before building."],"exampleFix":"// before\nQuarkusBootstrap.builder().setApplicationRoot(paths).setAppArtifact(dep)\n// after\nQuarkusBootstrap.builder().setAppArtifact(dep) // root taken from dep.getResolvedPaths()","handlingStrategy":"validation","validationCode":"QuarkusBootstrap.Builder b = QuarkusBootstrap.builder();\nif (appArtifact == null) b.setApplicationRoot(paths); else b.setAppArtifact(appArtifact);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide artifact-vs-directory mode once before building.","Do not merge configuration fragments that each set a different bootstrap source.","Rely on setAppArtifact for root derivation instead of setting roots manually."],"tags":["bootstrap","builder","illegal-state","configuration"],"backgroundTag":"conflicting-builder-options","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}