【问题标题】:InvalidInputException: Input path does not existInvalidInputException:输入路径不存在
【发布时间】:2015-12-25 10:45:16
【问题描述】:

运行 MapReduce 作业时出现以下异常:

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)

有人可以帮忙吗?是包文件的问题吗? 我给出的参数是“input.txt 输出”。

代码如下:

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);
    }

}

【问题讨论】:

  • 我也收到“作业无法解析为类型”错误

标签: java eclipse apache hadoop mapreduce


【解决方案1】:

这不是编译错误。
正如异常明确指出的那样,您的应用程序找不到文件 C:/Users/HARSH/workspace1/hadoop/words.txt

检查:

  • 文件存在且路径正确(尝试使用绝对路径)
  • 您有访问权限
  • 没有其他程序打开该文件

【讨论】:

  • 我已将文件 words.txt 作为命令行参数。以这种格式“words.txt outputdirectory_name”
  • SIr ,如何解决“作业无法解析为类型”
  • @HARSH 修复文件路径问题后,为该问题打开另一个问题。
  • 先生,这些异常意味着什么?org.apache.hadoop.mapred.JobClient.writeNewSplits(JobClient.java:885) at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient. java:779) 在 org.apache.hadoop.mapreduce.Job.submit(Job.java:432) 在 org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:447) 在 hadoop.wordcount.main(wordcount .java:70)
  • 先生,我在运行配置中指定为“\user\HARSH\input\words.txt\user\HARSH\output”@Alessandro Da Rugna.. 现在它只是在输出目录中给出我的 arrayIndexOutOfBoundsException (包含 args[1] 的代码行)。我现在该怎么办?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多