elastic/elasticsearch · error · FindException

Automatic-Module-Name: {e.getMessage()}

Error message

Automatic-Module-Name: {e.getMessage()}

What it means

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).

Source

Thrown at libs/core/src/main/java/org/elasticsearch/core/internal/provider/EmbeddedModulePath.java:68

                return descriptorForAutomatic(path);
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    // Generates and returns a module descriptor for an automatic module at the given path.
    // Currently, only automatic modules with a manifest name are supported.
    private static ModuleDescriptor descriptorForAutomatic(Path path) throws IOException {
        String moduleName = moduleNameFromManifestOrNull(path);
        if (moduleName == null) {
            throw new FindException("automatic module without a manifest name is not supported, for: " + path);
        }
        ModuleDescriptor.Builder builder;
        try {
            builder = ModuleDescriptor.newAutomaticModule(moduleName);
        } catch (IllegalArgumentException e) {
            throw new FindException(AUTOMATIC_MODULE_NAME + ": " + e.getMessage());
        }

        version(path.getFileName().toString()).ifPresent(builder::version);

        // scan the names of the entries in the exploded JAR
        var scan = scan(path);

        // all packages are exported and open, since the auto-module bit is set
        String separator = path.getFileSystem().getSeparator();
        builder.packages(
            scan.classFiles().stream().map(cf -> toPackageName(cf, separator)).flatMap(Optional::stream).collect(Collectors.toSet())
        );

        services(scan.serviceFiles(), path).entrySet().forEach(e -> builder.provides(e.getKey(), e.getValue()));
        return builder.build();
    }

    private EmbeddedModulePath() {}

View on GitHub (pinned to db6a809a66)

Solutions

  1. Inspect the actual value of Automatic-Module-Name in the jar's MANIFEST.MF (unzip -p x.jar META-INF/MANIFEST.MF).
  2. 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').
  3. Fix the manifest in the jar's build: `attributes('Automatic-Module-Name': 'org.example.mylib')`.
  4. If the bug is upstream, shade/patch the jar or open an issue with the dependency.

Example fix

// before — manifest has 'Automatic-Module-Name: my-module'

// after — legal dotted name
// manifest: 'Automatic-Module-Name: my.module'
Defensive patterns

Strategy: validation

Validate before calling

// Validate a candidate module name per JDK rules before packaging
static final Pattern MOD_NAME = Pattern.compile("[a-z][a-z0-9]*(\\.[a-z][a-z0-9]*)*");
boolean isValidModuleName(String n) { return n != null && MOD_NAME.matcher(n).matches(); }

Type guard

static boolean isLegalModuleName(String name) {
    try {
        ModuleDescriptor.newAutomaticModule(name);
        return true;
    } catch (IllegalArgumentException e) {
        return false;
    }
}

Try / catch

try {
    return EmbeddedModulePath.descriptorFor(path);
} catch (FindException e) {
    if (e.getMessage().startsWith("Automatic-Module-Name:")) {
        // the manifest value is invalid; fix it and rebuild the jar
        throw new RuntimeException("Invalid Automatic-Module-Name in " + path, e);
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/5e09ac2b5ad4dc84. Report an issue: GitHub.