apache/hadoop · error · IOException
Failure parsing JSON document: ${je.getMessage()}
Error message
Failure parsing JSON document: ${je.getMessage()} What it means
JSONHistoryViewerPrinter assembles the job view into an org.json JSONObject and streams it out; any JSONException raised while building (problematic puts) or writing the document is wrapped as IOException("Failure parsing JSON document: <je.getMessage()>", je). The underlying org.json message names the actual problem.
Source
Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JSONHistoryViewerPrinter.java:80
* machine-readable JSON format.
* @param ps the {@link PrintStream} to print to
* @throws IOException when a problem occurs while printing
*/
@Override
public void print(PrintStream ps) throws IOException {
json = new JSONObject();
Writer writer = null;
try {
printJobDetails();
printTaskSummary();
printTasks();
writer = new OutputStreamWriter(ps, StandardCharsets.UTF_8);
json.write(writer);
writer.flush();
} catch (JSONException je) {
throw new IOException("Failure parsing JSON document: " + je.getMessage(),
je);
} finally {
if (writer != null) {
writer.close();
}
}
}
private void printJobDetails() throws JSONException {
json.put("hadoopJob", job.getJobId().toString());
json.put("user", job.getUsername());
json.put("jobName", job.getJobname());
json.put("jobConf", job.getJobConfPath());
json.put("submittedAt", job.getSubmitTime());
json.put("launchedAt", job.getLaunchTime());
json.put("finishedAt", job.getFinishTime());
json.put("status", ((job.getJobStatus() == null) ?
"Incomplete" :job.getJobStatus()));View on GitHub (pinned to 2add963021)
Solutions
- Read the wrapped JSONException message to identify the offending field/operation.
- View the same file in the default human format ('human' printer) which tolerates the same data - if it prints, the issue is JSON-specific.
- Retry the JSON view on a history from a normally-completed job; abnormal (killed/failed-early) jobs can carry nulls that trip the printer.
- If a specific field consistently fails, patch the printer to null-guard that put and report it upstream with the JSONException message.
Example fix
# before hadoop job -history -format json <path>/job_*.jhist 2>&1 | head # IOException: Failure parsing JSON document: ... # after: same file, tolerant printer hadoop job -history <path>/job_*.jhist | head
Defensive patterns
Strategy: try-catch
Try / catch
catch (IOException e) when printing JSON history: if message starts with "Failure parsing JSON document", retry the same file with the human-format printer (new HumanReadableHistoryViewerPrinter path via format "human") before giving up.
Prevention
- Default automation to the human printer; use JSON only where needed.
- Expect abnormal (killed/failed-early) jobs to be the ones that trip JSON output.
- Capture the wrapped JSONException message to identify the offending field before patching.
When it happens
Trigger: Running HistoryViewer with format "json" on a history whose parsed job data triggers a JSONException - e.g. null/odd values put into the JSON object for abnormal jobs (killed jobs with unset finish times), or an I/O failure while the JSON writer flushes to the output stream.
Common situations: JSON output on incomplete/abnormal job histories; piping JSON viewer output into a closed/full output stream; automation scraping JSON for many jobs hitting one malformed record.
Related errors
- Incompatible event log version: ${version}
- Event schema string not parsed since its null
- Unknown mode: ${mode}
- Unable to initialize History Viewer
- MapReduce JobHistory WebApp Address does not contain a valid
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/97ff6892dfefee42.
Report an issue: GitHub.