title: Error from AVRO Mapreduce
body: <p>Getting the following error when I try to run mapreduce on avro:</p>
  
  <blockquote>
    <p>14/02/26 20:07:50 INFO mapreduce.Job: Task Id : attempt_1393424169778_0002_m_000001_0, Status : FAILED<br>
    Error: org.apache.avro.generic.GenericData.createDatumWriter(Lorg/apache/avro/Schema;)Lorg/apache/avro/io/DatumWriter;</p>
  </blockquote>
  
  <p>How can I fix this?</p>
  
  <p>I have Hadoop 2.2 up and running.<br>
  I'm using Avro 1.7.6.  </p>
  
  <p>Below is the code:</p>
  
  <pre><code>package avroColorCount;
  import java.io.IOException;
  
  import org.apache.avro.*;
  import org.apache.avro.Schema.Type;
  import org.apache.avro.mapred.*;
  import org.apache.hadoop.conf.*;
  import org.apache.hadoop.fs.Path;
  import org.apache.hadoop.mapred.*;
  import org.apache.hadoop.util.*;
  
  public class MapredColorCount extends Configured implements Tool {
  
    public static class ColorCountMapper extends AvroMapper&lt;User, Pair&lt;CharSequence, Integer&gt;&gt; {
      @Override
      public void map(User user, AvroCollector&lt;Pair&lt;CharSequence, Integer&gt;&gt; collector, Reporter reporter)
          throws IOException {
        CharSequence color = user.getFavoriteColor();
        // We need this check because the User.favorite_color field has type ["string", "null"]
        if (color == null) {
          color = "none";
        }
        collector.collect(new Pair&lt;CharSequence, Integer&gt;(color, 1));
      }
    }
  
    public static class ColorCountReducer extends AvroReducer&lt;CharSequence, Integer,
                                                              Pair&lt;CharSequence, Integer&gt;&gt; {
      @Override
      public void reduce(CharSequence key, Iterable&lt;Integer&gt; values,
                         AvroCollector&lt;Pair&lt;CharSequence, Integer&gt;&gt; collector,
                         Reporter reporter)
          throws IOException {
        int sum = 0;
        for (Integer value : values) {
          sum += value;
        }
        collector.collect(new Pair&lt;CharSequence, Integer&gt;(key, sum));
      }
    }
  
    public int run(String[] args) throws Exception {
      if (args.length != 2) {
        System.err.println("Usage: MapredColorCount &lt;input path&gt; &lt;output path&gt;");
        return -1;
      }
  
      JobConf conf = new JobConf(getConf(), MapredColorCount.class);
      conf.setJobName("colorcount");
  
      FileInputFormat.setInputPaths(conf, new Path(args[0]));
      FileOutputFormat.setOutputPath(conf, new Path(args[1]));
  
      AvroJob.setMapperClass(conf, ColorCountMapper.class);
      AvroJob.setReducerClass(conf, ColorCountReducer.class);
  
      // Note that AvroJob.setInputSchema and AvroJob.setOutputSchema set
      // relevant config options such as input/output format, map output
      // classes, and output key class.
      AvroJob.setInputSchema(conf, User.getClassSchema());
      AvroJob.setOutputSchema(conf, Pair.getPairSchema(Schema.create(Type.STRING),
          Schema.create(Type.INT)));
  
      JobClient.runJob(conf);
      return 0;
    }
  
    public static void main(String[] args) throws Exception {
      int res = ToolRunner.run(new Configuration(), new MapredColorCount(), args);
      System.exit(res);
    }
  }
  </code></pre>