-6

I get following exception, while running a MapReduce job:

15/12/25 16:00:07 INFO jvm.JvmMetrics: Initializing JVM Metrics with processName=JobTracker, sessionId=
15/12/25 16:00:07 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
15/12/25 16:00:07 WARN mapred.JobClient: No job jar file set.  User classes may not be found. See JobConf(Class) or JobConf#setJar(String).
Exception in thread "main" org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: file:/C:/Users/HARSH/workspace1/hadoop/words.txt
    at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.listStatus(FileInputFormat.java:224)
    at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getSplits(FileInputFormat.java:241)
    at org.apache.hadoop.mapred.JobClient.writeNewSplits(JobClient.java:885)
    at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:779)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:432)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:447)
    at hadoop.wordcount.main(wordcount.java:70)

Can anyone please help? Is the problem in the package file? Arguments I have given is "input.txt output".

Here is the code:

package hadoop;     

import org.apache.hadoop.io.IntWritable;
import java.io.IOException;
import java.util.*;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.*;

import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.*;

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;

public class wordcount {

    static public class wordmap extends  Mapper<IntWritable, Text, Text, IntWritable>
    {
        public void map(IntWritable key, Text value, Context context) throws IOException, InterruptedException
        {
            Text keys = new Text();
            IntWritable one= new IntWritable(1);
            StringTokenizer tokens= new StringTokenizer(value.toString());
            while(tokens.hasMoreTokens())
            {
                keys.set(tokens.nextToken());
                context.write(keys, one);
            }
        }
    }

    static public class wordred extends Reducer<Text, IntWritable, Text, IntWritable>
    {
        public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException
        {
            int sum=0;
            for (IntWritable count : values) 
            {
                sum=sum+ count.get();
            }
            context.write(key, new IntWritable(sum));
        }
    }

    public static void main(String args[]) throws Exception
    {
        Configuration conf=new Configuration();
        Job job= new Job(conf,"wordcount");
        job.setJarByClass(wordcount.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        job.setInputFormatClass(TextInputFormat.class);
        job.setOutputFormatClass(TextOutputFormat.class);

        job.setMapperClass(wordmap.class);
        job.setReducerClass(wordred.class);

        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        job.waitForCompletion(true);
    }

}
1
  • Also I am getting "Job cannot be resolved to a type" error Commented Dec 25, 2015 at 11:11

1 Answer 1

1

It's not a compilation error.
As the exception clearly states, your application cannot find the file C:/Users/HARSH/workspace1/hadoop/words.txt

Check that:

  • file exists and the path is correct (try using absolute paths)
  • you have access permission
  • no other program has the file open
Sign up to request clarification or add additional context in comments.

9 Comments

i have given the file words.txt as command line agrument. In this format" words.txt outputdirectory_name"
SIr ,How to resolve "Job cannot be resolved to a type"
@HARSH once you fixed the file path problem, open another question for that problem.
Sir what does these exceptions means???org.apache.hadoop.mapred.JobClient.writeNewSplits(JobClient.java:885) at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:779) at org.apache.hadoop.mapreduce.Job.submit(Job.java:432) at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:447) at hadoop.wordcount.main(wordcount.java:70)
Sir, i specified in run confguration as "\user\HARSH\input\words.txt\user\HARSH\output" @Alessandro Da Rugna.. Now its just giving my arrayIndexOutOfBoundsException at the output directory(code line containing args[1]). What should I do now?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.