0

map/reduce ジョブを実行しましたが、機能しません。このエラーを修正するにはどうすればよいですか?? 教えてください。

13/09/16 15:58:47 INFO mapred.JobClient: Task Id : attempt_201307081931_0006_m_000000_2, Status : FAILED
java.lang.ClassCastException: class com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$Text
at java.lang.Class.asSubclass(Class.java:3116)
at org.apache.hadoop.mapred.JobConf.getOutputKeyComparator(JobConf.java:774)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.<init>(MapTask.java:959)
at org.apache.hadoop.mapred.MapTask$NewOutputCollector.<init>(MapTask.java:674)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:756)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370)
at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1149)
at org.apache.hadoop.mapred.Child.main(Child.java:249)

私のソースコード:

WordCountMapper.java

public class WordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {

private final static IntWritable one = new IntWritable();
private Text word = new Text();

public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException{

    StringTokenizer itr = new StringTokenizer(value.toString());
    while(itr.hasMoreTokens()) {
        word.set(itr.nextToken());
        context.write(word, one);
    }
}
}

WordCountReducer.java

public class WordCountReducer extends Reducer<Text, IntWritable, Text, IntWritable> {

private IntWritable result = new IntWritable();

public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException{

    int sum = 0;
    for(IntWritable val : values){
        sum += val.get();
    }
    result.set(sum);
    context.write(key, result);
}
}

WordCount.java

public class WordCount {

public static void main(String[] args) throws Exception {

    Configuration conf = new Configuration();
    if(args.length != 2){
        System.err.println("Usage: WordCount <input> <output>");
        System.exit(2);
    }

    Job job = new Job(conf, "wordCount");

    job.setJarByClass(WordCount.class);
    job.setMapperClass(WordCountMapper.class);
    job.setReducerClass(WordCountReducer.class);

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

    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(IntWritable.class);

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

    job.waitForCompletion(true);
}
}
4

3 に答える 3

1

はい、IDE で LocalRunner を使用して Hadoop ジョブをテストしているときに、私もこの問題を抱えていました。

org.apache.hadoop.io.Text の代わりに CTRL + O(予告なし) を使用して、「com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider.Text」をインポートしました。

于 2015-05-16T01:46:37.057 に答える