elastic/elasticsearch · error · UserException
78
78
Error message
encountered [%d] error%s parsing [%s]%s[%d]: encountered improperly formatted JVM option in [%s] on line number [%d]: [%s]%s
What it means
Thrown by JvmOptionsParser when one or more lines in a jvm.options file are malformed (caught as JvmOptionsFileParserException and rewrapped as UserException CONFIG). The message lists each invalid line with its file and line number.
Source
Thrown at distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/JvmOptionsParser.java:128
e.jvmOptionsFile(),
System.lineSeparator()
);
StringBuilder msg = new StringBuilder(errorMessage);
int count = 0;
for (final Map.Entry<Integer, String> entry : e.invalidLines().entrySet()) {
count++;
final String message = String.format(
Locale.ROOT,
"[%d]: encountered improperly formatted JVM option in [%s] on line number [%d]: [%s]%s",
count,
e.jvmOptionsFile(),
entry.getKey(),
entry.getValue(),
System.lineSeparator()
);
msg.append(message);
}
throw new UserException(ExitCodes.CONFIG, msg.toString());
}
}
private List<String> jvmOptions(
ServerArgs args,
final Path config,
Path tmpDir,
final String esJavaOpts,
final Map<String, String> substitutions,
final Map<String, String> cliSysprops,
final MachineDependentHeap machineDependentHeap
) throws InterruptedException, IOException, JvmOptionsFileParserException, UserException {
final List<String> jvmOptions = readJvmOptionsFiles(config);
if (esJavaOpts != null) {
jvmOptions.addAll(Arrays.stream(esJavaOpts.split("\\s+")).filter(Predicate.not(String::isBlank)).toList());
}View on GitHub (pinned to db6a809a66)
Solutions
- Use the line number from the message to open jvm.options and inspect the exact offending line.
- Ensure every non-comment, non-blank line is a single valid JVM flag (-D, -X, or -XX:...).
- For values with spaces, use the appropriate JVM syntax (usually no spaces; use = for -D props).
- Re-run after editing to confirm zero parse errors.
Example fix
# jvm.options — before (line 42 malformed) -Xmx4g extra # after -Xmx4g
Defensive patterns
Strategy: validation
Validate before calling
for (String line : Files.readAllLines(jvmOptionsFile)) {
String t = line.trim();
if (t.isEmpty() || t.startsWith("#")) continue;
if (!t.startsWith("-D") && !t.startsWith("-X") && !t.startsWith("-XX:")) {
throw new IllegalArgumentException("Invalid JVM option line: " + line);
}
} Try / catch
try {
parser.jvmOptions(args, config, tmpDir, envOptions, substitutions, cliSysprops, mdh);
} catch (JvmOptionsFileParserException e) {
throw new UserException(ExitCodes.CONFIG, "Fix jvm.options: " + e.invalidLines());
} Prevention
- Lint jvm.options changes: each non-blank, non-comment line must be a single JVM flag.
- Avoid spaces inside option values; use = for -D properties.
- Validate config in CI before deploying.
When it happens
Trigger: A line in config/jvm.options or a vendor jvm.options file does not conform to the expected JVM-option syntax — e.g. contains stray characters, is not a -D/-X/-XX flag, or has whitespace in the middle of an option.
Common situations: Manually editing jvm.options and introducing a typo; copy-pasting a multi-word value without quoting; a CI pipeline templating jvm.options that emits a blank/garbage line.
Related errors
- Unable to parse number of bytes from [${totalMemoryBytesOpti
- Invalid jvm argument `{}` configure as systemProperty instea
- Elasticsearch could not determine the origin of JVM option [
- starting java failed with [%d] output: %s error: %s
- Negative memory size specified in [{option}]
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/a3eff1bdcf56d683.
Report an issue: GitHub.