hadoop - WARN mapred.JobClient : No job jar file set. 可能找不到用户类

标签 hadoop mapreduce

我的代码是

import java.io.IOException;
import java.util.*;

import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
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 word_count_new {

 public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
    private final static IntWritable one = new IntWritable(1);
    private Text word = new Text();

    public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        StringTokenizer tokenizer = new StringTokenizer(line);
        while (tokenizer.hasMoreTokens()) {
            word.set(tokenizer.nextToken());
            context.write(word, one);
        }
    }
 }

 public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {

    public void reduce(Text key, Iterable<IntWritable> values, Context context)
      throws IOException, InterruptedException {
        int sum = 0;
        for (IntWritable val : values) {
            sum += val.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(word_count_new.class);
    //   conf.setJar(word_count_new.jar);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(IntWritable.class);

    job.setMapperClass(Map.class);
    job.setReducerClass(Reduce.class);

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

    FileInputFormat.addInputPath(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));
    job.setJarByClass(word_count_new.class);
    job.waitForCompletion(true);

 }

}

下面是类文件和jar包:

-rw-r----- 1 ps993w hyhdev  2236 Apr  3 13:56 word_count_new.java
-rw-r----- 1 ps993w hyhdev  1870 Apr  3 13:58 word_count_new$Map.class
-rw-r----- 1 ps993w hyhdev  1638 Apr  3 13:58 word_count_new$Reduce.class
-rw-r----- 1 ps993w hyhdev  1510 Apr  3 13:58 word_count_new.class
-rw-r----- 1 ps993w hyhdev  2990 Apr  3 13:58 word_count_new.jar

错误是

[ps993w@hltd413 ~]$ hadoop jar word_count_new.jar word_count_new /user/ps993w/indata/input_line.dat /user/ps993w/wordcount/
14/04/03 15:53:13 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
14/04/03 15:53:13 WARN mapred.JobClient: No job jar file set.  User classes may not be found. See JobConf(Class) or JobConf#setJar(String).
14/04/03 15:53:13 INFO hdfs.DFSClient: Created HDFS_DELEGATION_TOKEN token 105404 for ps993w on 130.4.240.48:8020
14/04/03 15:53:13 INFO security.TokenCache: Got dt for hdfs://hltd410.hydc.sbc.com:8020/user/ps993w/.staging/job_201402241341_9518;uri=130.4.240.48:8020;t.service=130.4.240.48:8020
14/04/03 15:53:13 INFO input.FileInputFormat: Total input paths to process : 1
14/04/03 15:53:13 INFO lzo.GPLNativeCodeLoader: Loaded native gpl library
14/04/03 15:53:13 INFO lzo.LzoCodec: Successfully loaded & initialized native-lzo library [hadoop-lzo rev cf4e7cbf8ed0f0622504d008101c2729dc0c9ff3]
14/04/03 15:53:13 WARN snappy.LoadSnappy: Snappy native library is available
14/04/03 15:53:13 INFO util.NativeCodeLoader: Loaded the native-hadoop library
14/04/03 15:53:13 INFO snappy.LoadSnappy: Snappy native library loaded
14/04/03 15:53:13 INFO mapred.JobClient: Running job: job_201402241341_9518
14/04/03 15:53:14 INFO mapred.JobClient:  map 0% reduce 0%
14/04/03 15:53:24 INFO mapred.JobClient: Task Id : attempt_201402241341_9518_m_000000_0, Status : FAILED
java.lang.RuntimeException: java.lang.ClassNotFoundException: word_count_new$Map

请推荐

最佳答案

我遇到了同样的问题。问题是 hadoop 没有权限读取本地系统上的 jar 文件。

我从下面找到了这个解决方案:

关于hadoop - WARN mapred.JobClient : No job jar file set. 可能找不到用户类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22850532/

相关文章:

mongodb - 如何删除mapReduce中的 "value"?

hadoop - 如何找出从哪个主机提交的 Hadoop 作业?

hadoop - reducer 数量

database - 如何使外部引用表或数据库可用于 Hadoop MapReduce 作业?

mysql - Oozie 未在 AWS EC2 实例中启动 Mysql

java - 根据单词的长度在reducer上分类

eclipse - 雅虎 hadoop 教程

hadoop - mapreduce 框架基于什么决定是否启动组合器

java - hadoop map reduce 程序未运行不受支持的 major.minor 版本

hadoop - 使用 MapReduce 查找非对称对