apache/hadoop · error · IOException

wrong Writable class given

Error message

wrong Writable class given

What it means

TypedBytes Writable bridge guard: the class named in the streamed writable payload does not match the Writable instance supplied (or cannot be loaded as one), so deserialization cannot proceed onto it.

Solutions

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

Strategy: validation

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.

Appendix: 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)