{"record":{"id":"678c1c66f7bab99c","repo":"quarkusio/quarkus","slug":"maincomponent-is-null","errorCode":null,"errorMessage":"mainComponent is null","messagePattern":"mainComponent is null","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/app-model/src/main/java/io/quarkus/sbom/CoreSbomContributionConfig.java","lineNumber":377,"sourceCode":"        return bomRef + \"-\" + counter.incrementAndGet();\n    }\n\n    private ComponentHolder resolveMainComponent(\n            Map<ArtifactKey, ComponentHolder> compArtifacts,\n            Map<Path, ComponentHolder> compPaths,\n            List<ComponentHolder> compList) {\n        ComponentHolder main;\n        if (mainPurl != null) {\n            main = addComponentHolder(ComponentDescriptor.builder()\n                    .setPurl(mainPurl)\n                    .setPath(runnerPath), null, compArtifacts, compPaths, compList);\n        } else if (mainArtifact != null) {\n            main = addComponentHolder(toMavenDescriptor(mainArtifact), mainArtifact,\n                    compArtifacts, compPaths, compList);\n        } else if (!compList.isEmpty()) {\n            main = compList.get(0);\n        } else {\n            throw new RuntimeException(\"mainComponent is null\");\n        }\n        if (runnerPath != null && mainPurl == null) {\n            overridePath(main, runnerPath, compPaths);\n        }\n        if (mainDependencies != null) {\n            main.explicitDependencies = mainDependencies;\n        }\n        return main;\n    }\n\n    private static void overridePath(ComponentHolder holder, Path newPath,\n            Map<Path, ComponentHolder> compPaths) {\n        if (newPath.equals(holder.path)) {\n            return;\n        }\n        if (holder.path != null) {\n            compPaths.remove(holder.path);\n        }","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/sbom/CoreSbomContributionConfig.java#L359-L395","documentation":"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.","triggerScenarios":"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.","commonSituations":"Building unusual packaging types or empty applications; SBOM enabled on a build that skipped dependency resolution; internal build pipelines filtering out the runner artifact.","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"],"exampleFix":"// before\nmvn quarkus:build -Dquarkus.sbom.enabled=true -Dmdep.skip=true\n// after\nmvn quarkus:build -Dquarkus.sbom.enabled=true   # allow full dependency resolution","handlingStrategy":"validation","validationCode":"// before enabling SBOM, ensure a main artifact exists\nif (project.getArtifact().getFile() == null) { throw new IllegalStateException(\"Main artifact not built; cannot generate SBOM\"); }","typeGuard":null,"tryCatchPattern":"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; } }","preventionTips":["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"],"tags":["sbom","build","maven"],"backgroundTag":"sbom-main-component-missing","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"}