title: Hadoop: LongWritable cannot be cast to org.apache.hadoop.io.IntWritable
body: <p>I want to take a mean value of a temperature given in an input file and my Mapper and Reducer synatax seems fine to me but I am still getting the following error:</p>
  
  <pre><code> Unable to load realm info from SCDynamicStore
      13/02/17 08:03:28 INFO mapred.JobClient: Task Id : attempt_201302170552_0009_m_000000_1, Status : FAILED
      java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.IntWritable
          at org.apache.hadoop.examples.TempMeasurement$TempMapper.map(TempMeasurement.java:26)
          at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
          at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370)
          at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:396)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
          at org.apache.hadoop.mapred.Child.main(Child.java:249)
  </code></pre>
  
  <p>My Mapper function is this:</p>
  
  <pre><code>public static class TempMapper extends Mapper&lt;IntWritable, Text, IntWritable, FloatWritable&gt;{
  
  @Override
  protected void map(IntWritable key, Text value, Context context)
                  throws IOException, InterruptedException {
  
      //code for getting date and temperature
  
      String temp = columns.get(3);
      context.write(new IntWritable(year), new FloatWritable(Float.valueOf(temp)));
  }
  }
  </code></pre>
  
  <p>And Reduce is:</p>
  
  <pre><code>  public static class IntSumReducer
         extends Reducer&lt;IntWritable, FloatWritable, IntWritable ,FloatWritable&gt; {
      private FloatWritable result = new FloatWritable();
  
      public void reduce(IntWritable key, Iterable&lt;FloatWritable&gt; values,
                         Context context
                         ) throws IOException, InterruptedException {
  
        //code for making calculations    
  
        context.write(key, result);
      }
    }
  </code></pre>
  
  <p>Input file is as:</p>
  
  <pre><code>11111 , 0,19900101, 44.04 ,
  11112, 0, 19900102, 50.00,
  11113, 3, 19910203, 30.00,
  </code></pre>
  
  <p>Any help would be appreciated</p>