quarkusio/quarkus · error · java.lang.RuntimeException
mainComponent is null
Error message
mainComponent is null
What it means
During SBOM generation, CoreSbomContributionConfig.resolveMainComponent() computes the SBOM's 'main component' from the main artifact or, failing that, the first collected component. If neither exists, it throws 'mainComponent is null' — the application has no identifiable main artifact/component to anchor the SBOM.
Source
Thrown at independent-projects/bootstrap/app-model/src/main/java/io/quarkus/sbom/CoreSbomContributionConfig.java:377
return bomRef + "-" + counter.incrementAndGet();
}
private ComponentHolder resolveMainComponent(
Map<ArtifactKey, ComponentHolder> compArtifacts,
Map<Path, ComponentHolder> compPaths,
List<ComponentHolder> compList) {
ComponentHolder main;
if (mainPurl != null) {
main = addComponentHolder(ComponentDescriptor.builder()
.setPurl(mainPurl)
.setPath(runnerPath), null, compArtifacts, compPaths, compList);
} else if (mainArtifact != null) {
main = addComponentHolder(toMavenDescriptor(mainArtifact), mainArtifact,
compArtifacts, compPaths, compList);
} else if (!compList.isEmpty()) {
main = compList.get(0);
} else {
throw new RuntimeException("mainComponent is null");
}
if (runnerPath != null && mainPurl == null) {
overridePath(main, runnerPath, compPaths);
}
if (mainDependencies != null) {
main.explicitDependencies = mainDependencies;
}
return main;
}
private static void overridePath(ComponentHolder holder, Path newPath,
Map<Path, ComponentHolder> compPaths) {
if (newPath.equals(holder.path)) {
return;
}
if (holder.path != null) {
compPaths.remove(holder.path);
}View on GitHub (pinned to e1c734241f)
Solutions
- Build the application normally (a main artifact should always exist); run mvn package/quarkus:build without custom artifact filtering
- Disable SBOM generation if not needed (remove quarkus.sbom.enabled=true)
- Ensure dependency resolution isn't skipped (don't combine SBOM with -Dmaven.main.skip or similar)
- File a bug with the build log if a standard build triggers it
Example fix
// before mvn quarkus:build -Dquarkus.sbom.enabled=true -Dmdep.skip=true // after mvn quarkus:build -Dquarkus.sbom.enabled=true # allow full dependency resolution
Defensive patterns
Strategy: validation
Validate before calling
// before enabling SBOM, ensure a main artifact exists
if (project.getArtifact().getFile() == null) { throw new IllegalStateException("Main artifact not built; cannot generate SBOM"); } Try / catch
try { generateSbom(); } catch (RuntimeException e) { if ("mainComponent is null".equals(e.getMessage())) { log.error("No main artifact for SBOM; check build config"); } else { throw e; } } Prevention
- Don't skip dependency/artifact resolution when SBOM is enabled
- Only enable quarkus.sbom on standard package builds
- Keep the quarkus extension updated if SBOM misbehaves
When it happens
Trigger: Running with SBOM generation enabled (quarkus.sbom.enabled / -Dquarkus.sbom.enabled=true) when no main artifact was recorded and the component list is empty — e.g. building a bare/thin artifact without dependencies or the main artifact not being registered.
Common situations: Building unusual packaging types or empty applications; SBOM enabled on a build that skipped dependency resolution; internal build pipelines filtering out the runner artifact.
Related errors
- Failed to resolve application model <appArtifact> dependenci
- Failed to build enhanced artifact
- Failed to build quarkus application
- The <parentNodeName> element description is missing child <c
- Failed to locate element <name>
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/678c1c66f7bab99c.
Report an issue: GitHub.