java.lang.NoSuchMethodError:org.apache.hadoop.conf.Configuration.addDeprecation(Ljava /郎/字符串; [Ljava /郎/字符串;)

问题描述 投票:3回答:1

我使用的Java / Eclipse的/ Hadoop的2.2.0(包括所有必要的罐子)来运行一个样本地图使用下面的代码,但(以下堆栈跟踪)遇到例外情况在Ubuntu Reduce任务(本地单节点)。

我可以运行该取样字从Ubuntu控制台中的Hadoop计算的例子。

码:

import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class testhdfs
{
    public static class WordMapper extends Mapper<Text, Text, Text, Text>
    {
        private Text word = new Text();
        public void map(Text key, Text value, Context context) throws IOException, InterruptedException
        {
            StringTokenizer itr = new StringTokenizer(value.toString(),",");
            while (itr.hasMoreTokens())
            {
                word.set(itr.nextToken());
                context.write(key, word);
            }
        }
    }
    public static class AllTranslationsReducer
    extends Reducer<Text,Text,Text,Text>
    {
        private Text result = new Text();
        public void reduce(Text key, Iterable<Text> values,
        Context context
        ) throws IOException, InterruptedException
        {
            String translations = "";
            for (Text val : values)
            {
                translations += "|"+val.toString();
            }
            result.set(translations);
            context.write(key, result);
        }
    }
    public static void main(String[] args) throws Exception
    {
        Configuration conf = new Configuration();
        Job job = new Job(conf, "dictionary");
        job.setJarByClass(testhdfs.class);
        job.setMapperClass(WordMapper.class);
        job.setReducerClass(AllTranslationsReducer.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);
        job.setInputFormatClass(KeyValueTextInputFormat.class);
        FileInputFormat.addInputPath(job, new Path("/testext"));
        FileOutputFormat.setOutputPath(job, new Path("resulthdfs"));
        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}

堆栈跟踪:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.conf.Configuration.addDeprecation(Ljava/lang/String;[Ljava/lang/String;)V
    at org.apache.hadoop.mapreduce.util.ConfigUtil.addDeprecatedKeys(ConfigUtil.java:53)
    at org.apache.hadoop.mapreduce.util.ConfigUtil.loadResources(ConfigUtil.java:41)
    at org.apache.hadoop.mapreduce.Job.<clinit>(Job.java:108)
    at testhdfs.main(testhdfs.java:49)
java eclipse hadoop mapreduce
1个回答
-1
投票

NoSuchMethodError例外几乎总是意味着你有一些奇怪的问题dependency并拉动的一些错误jar或缺少jar

© www.soinside.com 2019 - 2024. All rights reserved.