title: Mapreduce Hadoop job exception Output directory already exists
body: <p>I'm running a mapreduce job with the following run code and it keeps giving me the following exception. I made sure that I remove the folder before starting the job but it doesn't work.</p>
  
  <p>The code:</p>
  
  <pre><code>    JobConf jobConf = new JobConf( getConf(), MPTU.class );
      jobConf.setJobName( "MPTU" );
  
      AvroJob.setMapperClass( jobConf, MPTUMapper.class );
      AvroJob.setReducerClass( jobConf, MPTUReducer.class );
  
      long milliSeconds = 1000 * 60 * 60;
      jobConf.setLong( "mapred.task.timeout", milliSeconds );
  
      Job job = new Job( jobConf );
      job.setJarByClass( MPTU.class );
  
      String paths = args[0] + "," + args[1];
      FileInputFormat.setInputPaths( job, paths );
      Path outputDir = new Path( args[2] );
      outputDir.getFileSystem( jobConf ).delete( outputDir, true );
      FileOutputFormat.setOutputPath( job, outputDir );
  
      AvroJob.setInputSchema( jobConf, Pair.getPairSchema( Schema.create( Type.LONG ), Schema.create( Type.STRING ) ) );
      AvroJob.setMapOutputSchema( jobConf, Pair.getPairSchema( Schema.create( Type.STRING ),
                                                               Schema.create( Type.STRING ) ) );
      AvroJob.setOutputSchema( jobConf,
                               Pair.getPairSchema( Schema.create( Type.STRING ), Schema.create( Type.STRING ) ) );
  
      job.setNumReduceTasks( 400 );
      job.submit();
      JobClient.runJob( jobConf );
  </code></pre>
  
  <p>The Exception:</p>
  
  <pre><code>13:31:39,268 ERROR UserGroupInformation:1335 - PriviledgedActionException as:msadri (auth:SIMPLE) cause:org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory file:/Users/msadri/Documents/files/linkage_output already exists
  Exception in thread "main" org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory file:/Users/msadri/Documents/files/linkage_output already exists
      at org.apache.hadoop.mapred.FileOutputFormat.checkOutputSpecs(FileOutputFormat.java:117)
      at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:937)
      at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:896)
      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:1332)
      at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:896)
      at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:870)
      at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1319)
      at com.reunify.socialmedia.RecordLinkage.MatchProfileTwitterUserHandler.run(MatchProfileTwitterUserHandler.java:58)
      at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
      at com.reunify.socialmedia.RecordLinkage.MatchProfileTwitterUserHandler.main(MatchProfileTwitterUserHandler.java:81)
  </code></pre>