apache/hadoop · error · ServiceLaunchException
40
40
Error message
Failed to parse: %s : %s
What it means
Same ServiceLauncher.parseArguments path, but the failure is a RuntimeException escaping GenericOptionsParser — the canonical case being an XML parse failure raised while a -conf file is loaded during parsing. The launcher wraps it into ServiceLaunchException (exit code 40, EXIT_COMMAND_ARGUMENT_ERROR) keeping the original argument string in the first %s and the causing exception in the second %s so the root cause stays visible.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/service/launcher/ServiceLauncher.java:967
confResourceUrls.add(file.toURI().toURL());
}
}
if (line.hasOption(ARG_CONFCLASS)) {
// new resources to instantiate as configurations
List<String> classnameList = Arrays.asList(
line.getOptionValues(ARG_CONFCLASS));
LOG.debug("Configuration classes {}", classnameList);
confClassnames.addAll(classnameList);
}
// return the remainder
return remainingArgs;
} catch (IOException e) {
// parsing problem: convert to a command argument error with
// the original text
throw new ServiceLaunchException(EXIT_COMMAND_ARGUMENT_ERROR, e);
} catch (RuntimeException e) {
// lower level issue such as XML parse failure
throw new ServiceLaunchException(EXIT_COMMAND_ARGUMENT_ERROR, e,
E_PARSE_FAILED + " %s : %s", argString, e);
}
}
/**
* Override point: create a generic options parser or subclass thereof.
* @param conf Hadoop configuration
* @param argArray array of arguments
* @return a generic options parser to parse the arguments
* @throws IOException on any failure
*/
protected GenericOptionsParser createGenericOptionsParser(Configuration conf,
String[] argArray) throws IOException {
return new MinimalGenericOptionsParser(conf, commandOptions, argArray);
}
/**
* Verify that all the specified filenames exist.View on GitHub (pinned to 2add963021)
Solutions
- Read the second %s — the wrapped exception names the XML file, line, and column of the problem
- Validate the file with `xmllint --noout conf.xml` (or an XML editor) and fix or regenerate it
- If you subclass ServiceLauncher, audit createGenericOptionsParser() overrides for runtime exceptions
- Re-run the exact command from the message once the config parses cleanly
Example fix
<!-- before: unterminated property --> <property><name>fs.defaultFS</name><value>hdfs://nn:8020</property> <!-- after --> <property><name>fs.defaultFS</name><value>hdfs://nn:8020</value></property>
Defensive patterns
Strategy: validation
Validate before calling
# fail fast on malformed XML before launching
for f in conf/*.xml; do
xmllint --noout "$f" || { echo "malformed: $f"; exit 1; }
done Try / catch
catch (ServiceLaunchException e) {
Throwable cause = (e.getCause() != null) ? e.getCause() : e;
// cause carries the underlying XML/parse error with file, line, column
log.error("launch failed, argv in message, cause below", cause);
} Prevention
- Run xmllint --noout over every -conf XML file in CI and deploy scripts
- Generate configs from templates that cannot emit truncated XML
- Never hand-edit deployed site files under time pressure without validation
When it happens
Trigger: Passing -conf/--conf with a not-well-formed XML file (unterminated tag, bad entity, wrong encoding) so Configuration loading inside the parser throws; a RuntimeException raised by an overridden createGenericOptionsParser() in a ServiceLauncher subclass; classpath problems surfacing while parser extensions load.
Common situations: Hand-edited site XML with typos; config files truncated mid-write by a crashed editor or deployment template; BOM or stray characters injected into XML by scripts; custom launcher subclasses throwing from parse hooks.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- EXIT_COMMAND_ARGUMENT_ERROR(40)
- EXIT_SERVICE_CREATION_FAILURE(56)
- 44
- Failed to load EC policy file: {policyFilePath}
- Bad EC policy configuration file: top-level element not <con
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/177a4cdf012f2ed0.
Report an issue: GitHub.