apache/hadoop · error · IOException
{} is incompatible with {} mode.
Error message
{} is incompatible with {} mode. What it means
During submit(), Job.setUseNewAPI() decides whether map/reduce stages run on the new org.apache.hadoop.mapreduce API or the old org.apache.hadoop.mapred API. It picks a mode per stage and calls ensureNotSet for the other generation's keys (e.g. 'mapred.mapper.class' vs mapreduce.job.map.class, 'mapred.input.format.class' vs INPUT_FORMAT_CLASS_ATTR). If a key from the wrong generation is set, it throws IOException('<attr> is incompatible with <new map API|map compatibility|new reduce API|reduce compatibility> mode.') naming the offending property.
Source
Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Job.java:1361
*/
public void setProfileParams(String value) {
ensureState(JobState.DEFINE);
conf.setProfileParams(value);
}
/**
* Set the ranges of maps or reduces to profile. setProfileEnabled(true)
* must also be called.
* @param newValue a set of integer ranges of the map ids
*/
public void setProfileTaskRange(boolean isMap, String newValue) {
ensureState(JobState.DEFINE);
conf.setProfileTaskRange(isMap, newValue);
}
private void ensureNotSet(String attr, String msg) throws IOException {
if (conf.get(attr) != null) {
throw new IOException(attr + " is incompatible with " + msg + " mode.");
}
}
/**
* Sets the flag that will allow the JobTracker to cancel the HDFS delegation
* tokens upon job completion. Defaults to true.
*/
public void setCancelDelegationTokenUponJobCompletion(boolean value) {
ensureState(JobState.DEFINE);
conf.setBoolean(JOB_CANCEL_DELEGATION_TOKEN, value);
}
/**
* Default to the new APIs unless they are explicitly set or the old mapper or
* reduce attributes are used.
* @throws IOException if the configuration is inconsistent
*/
private void setUseNewAPI() throws IOException {View on GitHub (pinned to 2add963021)
Solutions
- Choose one API generation: conf.unset("mapred.mapper.class"), conf.unset("mapred.input.format.class"), etc. for every old key you replace with new-API setters
- Before submit(), scan both key families and fail fast with your own message listing duplicates
- When loading legacy job.xml files, unset old keys for any slot you set programmatically
- Check mapreduce partitions too: if numReduceTasks != 0 the partitioner keys are also mutually exclusive
Example fix
// before
conf.set("mapred.mapper.class", MyOldMapper.class.getName());
job.setMapperClass(MyNewMapper.class); // sets mapreduce.job.map.class
job.submit(); // IOException: mapred.mapper.class is incompatible with new map API mode.
// after
conf.unset("mapred.mapper.class");
job.setMapperClass(MyNewMapper.class);
job.submit(); Defensive patterns
Strategy: validation
Validate before calling
// fail fast on mixed old/new API keys before submit()
String[][] pairs = {
{"mapred.mapper.class", "mapreduce.job.map.class"},
{"mapred.input.format.class", "mapreduce.job.inputformat.class"},
{"mapred.reducer.class", "mapreduce.job.reduce.class"},
{"mapred.output.format.class", "mapreduce.job.outputformat.class"},
{"mapred.partitioner.class", "mapreduce.job.partitioner.class"}
};
for (String[] p : pairs) {
if (conf.get(p[0]) != null && conf.get(p[1]) != null) {
throw new IOException("Both " + p[0] + " and " + p[1] + " are set; unset one API generation");
}
} Prevention
- Pick one API generation per job and lint the conf for the other generation's keys
- unset() old keys when loading legacy job.xml files
- Watch map-only jobs: output-format keys are checked in the map branch when reduces == 0
When it happens
Trigger: Loading a job.xml written for the old mapred API and then calling new-API setters (job.setMapperClass) on the same conf; setting 'mapred.input.format.class'/'mapred.partitioner.class' while INPUT_FORMAT_CLASS_ATTR/MAP_CLASS_ATTR are also present; setting 'mapred.output.format.class' when the new OUTPUT_FORMAT_CLASS_ATTR is set and numReduceTasks is 0 (the reduce-mode branch only runs with reduces, so map-only jobs check output format in the map branch).
Common situations: Migrating Hadoop 1.x jobs to 2.x/3.x; third-party frameworks that write old key names; copying configuration snippets that mix JobConf-style and Job-style examples; leftover keys in cluster-wide mapred-site.xml.
Related errors
- Invalid specification for distributed-cache artifacts of typ
- File name can't be empty string
- Can't get Master Kerberos principal for use as renewer
- Split metadata size exceeded {maxMetaInfoSize}. Aborting job
- Invalid reservationId: {} specified for the app: {}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/66ad21f9e0b53547.
Report an issue: GitHub.