{"record":{"id":"5e09ac2b5ad4dc84","repo":"elastic/elasticsearch","slug":"automatic-module-name-e-getmessage","errorCode":null,"errorMessage":"Automatic-Module-Name: {e.getMessage()}","messagePattern":"Automatic-Module-Name: (.+?)","errorType":"exception","errorClass":"FindException","httpStatus":null,"severity":"error","filePath":"libs/core/src/main/java/org/elasticsearch/core/internal/provider/EmbeddedModulePath.java","lineNumber":68,"sourceCode":"                return descriptorForAutomatic(path);\n            }\n        } catch (IOException e) {\n            throw new UncheckedIOException(e);\n        }\n    }\n\n    // Generates and returns a module descriptor for an automatic module at the given path.\n    // Currently, only automatic modules with a manifest name are supported.\n    private static ModuleDescriptor descriptorForAutomatic(Path path) throws IOException {\n        String moduleName = moduleNameFromManifestOrNull(path);\n        if (moduleName == null) {\n            throw new FindException(\"automatic module without a manifest name is not supported, for: \" + path);\n        }\n        ModuleDescriptor.Builder builder;\n        try {\n            builder = ModuleDescriptor.newAutomaticModule(moduleName);\n        } catch (IllegalArgumentException e) {\n            throw new FindException(AUTOMATIC_MODULE_NAME + \": \" + e.getMessage());\n        }\n\n        version(path.getFileName().toString()).ifPresent(builder::version);\n\n        // scan the names of the entries in the exploded JAR\n        var scan = scan(path);\n\n        // all packages are exported and open, since the auto-module bit is set\n        String separator = path.getFileSystem().getSeparator();\n        builder.packages(\n            scan.classFiles().stream().map(cf -> toPackageName(cf, separator)).flatMap(Optional::stream).collect(Collectors.toSet())\n        );\n\n        services(scan.serviceFiles(), path).entrySet().forEach(e -> builder.provides(e.getKey(), e.getValue()));\n        return builder.build();\n    }\n\n    private EmbeddedModulePath() {}","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/core/src/main/java/org/elasticsearch/core/internal/provider/EmbeddedModulePath.java#L50-L86","documentation":"Thrown as a FindException by EmbeddedModulePath.descriptorForAutomatic when ModuleDescriptor.newAutomaticModule(moduleName) rejects the name extracted from the Automatic-Module-Name manifest attribute. The JDK enforces strict module-name rules (no dashes, valid Java identifiers separated by dots); the original IllegalArgumentException's message is re-exposed prefixed with 'Automatic-Module-Name:'. This is a manifest-content bug, not a missing-attribute one (error 471 covers the missing case).","triggerScenarios":"An embedded jar's Automatic-Module-Name attribute contains an invalid module name: e.g. 'my-module' (dashes illegal), '9module' (leading digit), '' (empty), or contains characters not legal in a module name. ModuleDescriptor.newAutomaticModule throws IllegalArgumentException which is wrapped at line 68.","commonSituations":"Deriving the manifest attribute from a Maven artifactId that contains dashes without converting to dots. Hand-editing MANIFEST.MF with a typo. Shading multiple jars and merging manifests with a malformed attribute. A dependency whose published manifest is wrong upstream.","solutions":["Inspect the actual value of Automatic-Module-Name in the jar's MANIFEST.MF (unzip -p x.jar META-INF/MANIFEST.MF).","Rename the module to a legal dotted form: replace dashes with dots, ensure each segment is a valid Java identifier (e.g. 'my.module' not 'my-module').","Fix the manifest in the jar's build: `attributes('Automatic-Module-Name': 'org.example.mylib')`.","If the bug is upstream, shade/patch the jar or open an issue with the dependency."],"exampleFix":"// before — manifest has 'Automatic-Module-Name: my-module'\n\n// after — legal dotted name\n// manifest: 'Automatic-Module-Name: my.module'","handlingStrategy":"validation","validationCode":"// Validate a candidate module name per JDK rules before packaging\nstatic final Pattern MOD_NAME = Pattern.compile(\"[a-z][a-z0-9]*(\\\\.[a-z][a-z0-9]*)*\");\nboolean isValidModuleName(String n) { return n != null && MOD_NAME.matcher(n).matches(); }","typeGuard":"static boolean isLegalModuleName(String name) {\n    try {\n        ModuleDescriptor.newAutomaticModule(name);\n        return true;\n    } catch (IllegalArgumentException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    return EmbeddedModulePath.descriptorFor(path);\n} catch (FindException e) {\n    if (e.getMessage().startsWith(\"Automatic-Module-Name:\")) {\n        // the manifest value is invalid; fix it and rebuild the jar\n        throw new RuntimeException(\"Invalid Automatic-Module-Name in \" + path, e);\n    }\n    throw e;\n}","preventionTips":["Use a legal dotted module name; replace dashes with dots (my-lib -> my.lib).","Each segment must start with a letter and contain only [a-z0-9].","Set the attribute in the build, not by hand-editing manifests.","Validate the name with ModuleDescriptor.newAutomaticModule during build checks."],"tags":["modules","classloader","jpms","manifest","validation","provider","elasticsearch-core"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}