title: MapReduce with Hadoop: Type mismatch
body: <p>I'm running a simple hadoop program, and I get the following error:</p>
  
  <pre><code>java.io.IOException: Type mismatch in key from map: expected org.apache.hadoop.io.Text, recieved org.apache.hadoop.io.LongWritable
  </code></pre>
  
  <p>Mapper:</p>
  
  <pre><code>public static class myMapper extends Mapper&lt;LongWritable, Text, Text, Text&gt;
  public void map(LongWritable key, Text line,OutputCollector&lt;Text,Text&gt; output, Reporter reporter) throws IOException, InterruptedException
  </code></pre>
  
  <p>Reducer:</p>
  
  <pre><code>public static class triangleCounterReducer extends Reducer&lt;Text, Text, Text, Text&gt; 
  public void reduce(Text key,Iterable&lt;Text&gt; line,OutputCollector&lt;Text,Text&gt; output,Reporter reporter) throws IOException, InterruptedException
  </code></pre>
  
  <p>Main:</p>
  
  <pre><code>...
  job.setOutputKeyClass(Text.class);
  job.setOutputValueClass(Text.class);
  job.setMapOutputKeyClass(Text.class);
  job.setMapOutputValueClass(Text.class);
  ...
  </code></pre>
  
  <p>How can i fix this????</p>