gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 14:41:21 27 4
gpt4 key购买 nike

我的代码是

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com