apache/hadoop · error · IOException
Unable to initialize History Viewer
Error message
Unable to initialize History Viewer
What it means
HistoryViewer requires the history file's base name to look like a job history name: it splits on '_' and requires at least 2 segments (job_<id>...). When the name has no '_' at all (jobDetails.length < 2), it prints "Ignore unrecognized file: <name>" to stderr and throws IOException("Unable to initialize History Viewer"). The errorIndex points at the throw inside the name check (HistoryViewer.java:85).
Source
Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/jobhistory/HistoryViewer.java:85
* Constructs the HistoryViewer object.
* @param historyFile the fully qualified Path of the History File
* @param conf the Configuration file
* @param printAll toggle to print all status to only killed/failed status
* @param format the output format to use
* @throws IOException when there is a problem parsing the history file
*/
public HistoryViewer(String historyFile, Configuration conf, boolean printAll,
String format) throws IOException {
String errorMsg = "Unable to initialize History Viewer";
try {
Path jobFile = new Path(historyFile);
fs = jobFile.getFileSystem(conf);
String[] jobDetails =
jobFile.getName().split("_");
if (jobDetails.length < 2) {
// NOT a valid name
System.err.println("Ignore unrecognized file: " + jobFile.getName());
throw new IOException(errorMsg);
}
JobHistoryParser parser = new JobHistoryParser(fs, jobFile);
job = parser.parse();
String scheme = WebAppUtils.getHttpSchemePrefix(fs.getConf());
if (HUMAN_FORMAT.equalsIgnoreCase(format)) {
jhvp = new HumanReadableHistoryViewerPrinter(job, printAll, scheme);
} else if (JSON_FORMAT.equalsIgnoreCase(format)) {
jhvp = new JSONHistoryViewerPrinter(job, printAll, scheme);
} else {
System.err.println("Invalid format specified: " + format);
throw new IllegalArgumentException(errorMsg);
}
} catch(IOException e) {
throw new IOException(errorMsg, e);
}
}
/**View on GitHub (pinned to 2add963021)
Solutions
- Pass the real history file: job_<jobid>[-...].jhist from the Yarn done/intermediatedone/ history directories.
- Validate the name before constructing the viewer: require a '_' in the file name.
- Check stderr - the preceding 'Ignore unrecognized file' line names the offending file.
- List the history directory and copy the exact .jhist name.
Example fix
// before
new HistoryViewer("/user/me/Logs/jobconf.xml", conf, true);
// after
new HistoryViewer("/tmp/hadoop-yarn/staging/history/done/2026/08/22/000000/"
+ "job_1690000000000_0001-1690000000000-user-word+count-1-0-user-StreamJob.jhist",
conf, true); Defensive patterns
Strategy: validation
Validate before calling
String name = Path.getPathWithoutSchemeAndAuthority(historyPath).getName();
if (name.split("_").length < 2) {
throw new IllegalArgumentException("Not a job history file name (expected job_* pattern): " + name);
} Prevention
- Pass only real .jhist files whose names start with 'job_'.
- In directory scans, filter file names on ^job_.* before constructing HistoryViewer.
- Watch stderr - 'Ignore unrecognized file:' names the bad file before the throw.
When it happens
Trigger: Constructing HistoryViewer (or running 'mapreduce job -history') with a path whose file name contains no underscore - e.g. 'summary.txt', 'jobconf', a directory-ish name, or a mistyped/garbled path.
Common situations: Passing the job conf/xml or a log file instead of the .jhist; shell scripts globbing the wrong directory; typos in the history path; tools that rename history files dropping the job_<submitter> pattern.
Related errors
- Incompatible event log version: ${version}
- Event schema string not parsed since its null
- Unknown mode: ${mode}
- Failure parsing JSON document: ${je.getMessage()}
- MapReduce JobHistory WebApp Address does not contain a valid
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/3663836a7afeac79.
Report an issue: GitHub.