quarkusio/quarkus · error · IllegalStateException
Cannot set both app artifact and application root
Error message
Cannot set both app artifact and application root
What it means
QuarkusBootstrap.Builder.setApplicationRoot throws this IllegalStateException when an app artifact was already set. The builder is mutually exclusive: an application is based either on an app artifact (ResolvedDependency, which derives the root itself) or on an explicit application root path collection, never both.
Source
Thrown at independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/QuarkusBootstrap.java:361
Set<ArtifactKey> excludedDependencies = Collections.emptySet();
boolean disableClasspathCache;
ApplicationModel existingModel;
final Set<ArtifactKey> localArtifacts = new HashSet<>();
boolean auxiliaryApplication;
List<ArtifactKey> parentFirstArtifacts = new ArrayList<>();
Supplier<DependencyInfoProvider> depInfoProvider;
public Builder() {
}
public Builder setApplicationRoot(Path applicationRoot) {
this.applicationRoot = PathList.of(applicationRoot);
return this;
}
public Builder setApplicationRoot(PathCollection applicationRoot) {
if (appArtifact != null) {
throw new IllegalStateException("Cannot set both app artifact and application root");
}
this.applicationRoot = applicationRoot;
return this;
}
public Builder addAdditionalApplicationArchive(AdditionalDependency path) {
additionalApplicationArchives.add(path);
return this;
}
public Builder addAdditionalApplicationArchives(Collection<AdditionalDependency> path) {
additionalApplicationArchives.addAll(path);
return this;
}
public Builder addAdditionalDeploymentArchive(Path path) {
additionalDeploymentArchives.add(path);
return this;View on GitHub (pinned to e1c734241f)
Solutions
- Call only one of setAppArtifact or setApplicationRoot; setAppArtifact already derives the application root from the artifact's resolved paths.
- If you need custom roots together with an artifact, pass the artifact paths explicitly via setApplicationRoot alone and skip setAppArtifact.
- Guard the builder chain: set application root only when appArtifact is not yet configured.
Example fix
// before QuarkusBootstrap.builder().setAppArtifact(dep).setApplicationRoot(paths) // after QuarkusBootstrap.builder().setAppArtifact(dep) // application root derived automatically
Defensive patterns
Strategy: validation
Validate before calling
QuarkusBootstrap.Builder b = QuarkusBootstrap.builder(); // choose exactly one source of truth: if (useArtifact) b.setAppArtifact(dep); else b.setApplicationRoot(paths);
Prevention
- Never chain setAppArtifact and setApplicationRoot in the same builder.
- Encapsulate bootstrap construction in one helper that picks a single mode.
- Remember setAppArtifact already derives the application root.
When it happens
Trigger: Calling QuarkusBootstrap.builder().setAppArtifact(dep).setApplicationRoot(paths) — i.e. invoking setApplicationRoot after setAppArtifact on the same Builder.
Common situations: Test or tooling code that copies multiple configuration styles, framework adapters that set defaults via app artifact and then layer user-specified roots on top.
Related errors
- Cannot set both application root and app artifact
- Unrecognized option for quarkus.bootstrap.misaligned-platfor
- Build time property cannot be changed at runtime: ${mismatch
- Failed to run application
- Client ID cannot be empty
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/b7d55ce22a7148f2.
Report an issue: GitHub.