{"record":{"id":"0df27a7d6594e9b5","repo":"quarkusio/quarkus","slug":"build-failed-during-jlink-exit-code","errorCode":null,"errorMessage":"Build failed during jlink (exit code )","messagePattern":"Build failed during jlink \\(exit code \\)","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"extensions/packaging/jlink/deployment/src/main/java/io/quarkus/jlink/deployment/JLinkSteps.java","lineNumber":252,"sourceCode":"                stagedOutput.bootModulePath().values().stream().map(Path::toString).toArray(String[]::new)));\n\n        // todo: include the whole boot path until --bind-services works\n        jlinkArgs.add(\"--add-modules\");\n        jlinkArgs.add(addedModules);\n\n        // everything looks good; make the directory for the image output\n        Files.createDirectories(imagePath.getParent());\n        log.info(\"Building image with jlink\");\n        log.debugf(\"JLink arguments: %s\", String.join(\"\\n\\t\", jlinkArgs));\n        Instant start = Instant.now();\n        int result = jlinkProvider.run(\n                new PrintWriter(new LogWriter(jlinkOut, Logger.Level.INFO)),\n                new PrintWriter(new LogWriter(jlinkOut, Logger.Level.WARN)),\n                jlinkArgs.toArray(String[]::new));\n        Instant end = Instant.now();\n        Duration duration = end.compareTo(start) < 0 ? Duration.ZERO : Duration.between(start, end);\n        if (result != 0) {\n            throw new BuildException(\"Build failed during jlink (exit code \" + result + \")\");\n        }\n        // produce the dynamic lib files\n        // bundle dynamic modules into the image\n        Path lib = config.outputDirectory().resolve(config.imagePath()).resolve(\"lib\").resolve(\"quarkus\");\n        Files.createDirectories(lib);\n        final AppModuleModel model = moduleInfoItem.model();\n        Map<String, ModuleInfo> modulesByName = model.modulesByName();\n        for (ModuleInfo moduleInfo : modulesByName.values()) {\n            String moduleName = moduleInfo.name();\n            if (model.bootModules().contains(moduleName)) {\n                // skip boot modules\n                continue;\n            }\n            // TODO: create an actual manifest (if needed)\n            ModuleWriter.writeModule(moduleInfo, lib.resolve(moduleInfo.name()), new Manifest(), false);\n        }\n\n        log.infof(\"JLink image produced in %s at %s; to run the image, execute %s in that directory\",","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/packaging/jlink/deployment/src/main/java/io/quarkus/jlink/deployment/JLinkSteps.java#L234-L270","documentation":"The jlink tool invoked by JLinkSteps.jlink returned a non-zero exit code, so the image could not be produced. The step wraps the raw jlink failure in a Quarkus BuildException with the exit code. The underlying reason is in the log output emitted just above via LogWriter.","triggerScenarios":"The external jlink command (JLink) exits non-zero, e.g. due to missing modules, duplicate/invalid module descriptors, bad --add-modules/launcher options, or insufficient disk space.","commonSituations":"Referencing modules not present in the JDK/module path; split packages across modules; invalid image name or output paths; running on a JRE without jlink; corrupted Maven/incremental state.","solutions":["Read the jlink INFO/WARN log lines printed immediately before the exception for the real cause","Verify all modules referenced (including app modules and JDK modules) resolve — run `jlink` manually with the same args to reproduce","Remove duplicate module artifacts from the dependency tree (mvn dependency:tree)","Ensure a full JDK (not JRE) is used and there is adequate disk space in the output directory","Clean build to rule out stale generated module-info files"],"exampleFix":"// before: module referenced in config is not on module path\nquarkus.jlink.add-modules java.sql,com.example.nonexistent\n// after\nquarkus.jlink.add-modules java.sql,com.example.app","handlingStrategy":"validation","validationCode":"// pre-validate modules referenced by jlink config exist on the module path\nfor (String m : jlinkConfig.addModules()) {\n    ModuleFinder mf = ModuleFinder.of(modulePathEntries);\n    if (mf.find(m).isEmpty()) {\n        throw new IllegalArgumentException(\"Module not on module path: \" + m);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    jlink(config, moduleInfoItem, ...);\n} catch (BuildException e) {\n    // jlink logs the root cause at INFO/WARN just before this; surface it\n    throw new IllegalStateException(\"jlink failed; see jlink log output above for the real cause\", e);\n}","preventionTips":["Always read the jlink log lines printed before the exception","Use a full JDK so the jlink tool is available","Keep dependency versions aligned to avoid duplicate module descriptors","Verify disk space in the output directory before packaging"],"tags":["jlink","native-image","build"],"backgroundTag":"jlink-build-failed","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"}