apache/hadoop · error · IOException

wrong Writable class given

Error message

wrong Writable class given

What it means

Error "wrong Writable class given" thrown in apache/hadoop.

Source

Thrown at hadoop-tools/hadoop-streaming/src/main/java/org/apache/hadoop/typedbytes/TypedBytesWritableInput.java:367

  public <K extends WritableComparable<? super K>> SortedMapWritable<K>
    readSortedMap() throws IOException {
    return readSortedMap((SortedMapWritable<K>)null);
  }
  
  public Writable readWritable(Writable writable) throws IOException {
    ByteArrayInputStream bais = new ByteArrayInputStream(in.readBytes());
    DataInputStream dis = new DataInputStream(bais);
    String className = WritableUtils.readString(dis);
    if (writable == null) {
      try {
        Class<? extends Writable> cls = 
          conf.getClassByName(className).asSubclass(Writable.class);
        writable = (Writable) ReflectionUtils.newInstance(cls, conf);
      } catch (ClassNotFoundException e) {
        throw new IOException(e);
      }
    } else if (!writable.getClass().getName().equals(className)) {
      throw new IOException("wrong Writable class given");
    }
    writable.readFields(dis);
    return writable;
  }

  public Writable readWritable() throws IOException {
    return readWritable(null);
  }

  public Configuration getConf() {
    return conf;
  }

  public void setConf(Configuration conf) {
    this.conf = conf;
  }
  
}

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass the Writable class that matches the data actually written in the typedbytes stream.

When it happens

Trigger: TypedBytesWritableInput is asked to read a Writable into an instance whose class does not match the expected Writable type.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/e3df2d0616aebfac. Report an issue: GitHub.