title: Hadoop MapReduce Job Input File ClassNotFound
body: <p>I am building a sample Map/Reduce task on a hadoop cluster comprising two nodes - master/slave and slave. 
  Following are my specs:</p>
  
  <pre><code>$HADOOP_HOME = /usr/local/hadoop
  My M/R classfiles path = $HADOOP_HOME/MyMapRed_classes
  My Mapper classfile = $HADOOP_HOME/MyMapRed_classes/MyMapper
  My Reducer classfile = $HADOOP_HOME/MyMapRed_classes/MyReducer
  My Jar path = $HADOOP_HOME/MyMapred/MyMapRed.jar
  My HDFS Input Path = /user/hadoop/MyMapRed/inputfile
  My HDFS Output Path = /user/hadoop/MyMapRed_output
  </code></pre>
  
  <p>I am running the M/R task as follows</p>
  
  <pre><code>&lt;myusername&gt;@localhost:/usr/local/hadoop$ bin/hadoop jar $HADOOP_HOME/MyMapRed/MyMapRed.jar -input /user/hadoop/MyMapRed/inputfile -output /user/hadoop/MyMapRed_output/ -mapper $HADOOP_HOME/MyMapRed_classes/MyMapper -reducer $HADOOP_HOME/MyMapRed_classes/MyReducer
  </code></pre>
  
  <p>But it seems it is not being able to find the input file as evident from below message </p>
  
  <pre><code>Exception in thread "main" java.lang.ClassNotFoundException: -input
  at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:264)
  at org.apache.hadoop.util.RunJar.main(RunJar.java:149)
  </code></pre>
  
  <p>Below is the MyMapRed class that I am using. It has as input a list of  pairs. The reducer is supposed to give the average Val per group. </p>
  
  <pre><code>import java.io.IOException;
  import java.util.Iterator;
  import org.apache.hadoop.fs.Path;
  import org.apache.hadoop.io.DoubleWritable;
  import org.apache.hadoop.io.Text;
  
  import org.apache.hadoop.mapred.FileInputFormat;
  import org.apache.hadoop.mapred.FileOutputFormat;
  import org.apache.hadoop.mapred.MapReduceBase;
  import org.apache.hadoop.mapred.Mapper;
  import org.apache.hadoop.mapred.OutputCollector;
  import org.apache.hadoop.mapred.Reducer;
  import org.apache.hadoop.mapred.Reporter;
  import org.apache.hadoop.mapred.JobClient;
  import org.apache.hadoop.mapred.JobConf;
  import org.apache.hadoop.mapred.TextInputFormat;
  import org.apache.hadoop.mapred.TextOutputFormat;
  
  
  public class MyMapRed {
  
  public static class MyMapper extends MapReduceBase 
  implements Mapper&lt;Text, Text, Text, DoubleWritable&gt; {
  
      private final static Text Group = new Text();
      private final static DoubleWritable Val = new DoubleWritable();
  
      public void map(Text key, Text value, OutputCollector&lt;Text, DoubleWritable&gt; output, Reporter reporter) 
          throws IOException {
          String line = value.toString();
          String[] KeyAndVal = line.split("\t",2);
          Group.set(KeyAndVal[0]);
          Val.set(Double.valueOf(KeyAndVal[1]));
          output.collect(Group, Val);
      }
  }
  
  public static class MyReducer extends MapReduceBase 
  implements Reducer&lt;Text, DoubleWritable, Text, DoubleWritable&gt; {
      public void reduce(Text key, Iterator&lt;DoubleWritable&gt; values,
              OutputCollector&lt;Text, DoubleWritable&gt; output, Reporter reporter)
              throws IOException {
          DoubleWritable val = new DoubleWritable();
          double valSum = 0.0;
          int valCnt = 0;
          while (values.hasNext()) {
              val = values.next();
              valSum += val.get();
              valCnt++;
          }
          if (valCnt&gt;0)
              valSum = valSum/valCnt;
          output.collect(key, new DoubleWritable(valSum));
      }
  }
  
  
  public static void main(String[] args) {
      JobClient client = new JobClient();
      JobConf conf = new JobConf(MyMapRed.class);
      conf.setJobName("MyMapRed");
  
      conf.setOutputKeyClass(Text.class);
      conf.setOutputValueClass(DoubleWritable.class);
  
      conf.setMapperClass(MyMapper.class);
      conf.setReducerClass(MyReducer.class);
  
      conf.setInputFormat(TextInputFormat.class);
      conf.setOutputFormat(TextOutputFormat.class);
  
      FileInputFormat.addInputPath(conf, new Path("input"));
      FileOutputFormat.setOutputPath(conf, new Path("output"));
  
      client.setConf(conf);
  
      try {
          JobClient.runJob(conf);
      } catch (Exception e) {
          e.printStackTrace();
      }
  
  }
  }
  </code></pre>
  
  <p>Can anybody suggest what I am missing out for ClassNotFoundException to be raised ? </p>