2017-12-31 161 views
0

減速機に送信するが、私はこのエラーが表示されます:私はNoSuchMethodErrorを修正するにはどうすればよい:私はhadoop.Iにプロジェクトを1D文字列array.its名は「言葉」.I</p> <p>がしたいですしている書いているorg.apache.hadoop.mapred.InputSplit.write

Exception in thread "main" java.lang.NoSuchMethodError:org.apache.hadoop.mapred .InputSplit.write(Ljava/io/DataOutput;)V 

どうすればよいですか?

誰でも手伝ってもらえますか?

これは私のマッパーである:私はhadoopmapreduceツールを学んでいたとき、私は伝統的なWordCountプログラムから離れて自分のプログラムを書いて、後でそのためにjarファイルをエクスポート

public abstract class Mapn implements Mapper<LongWritable, Text, Text, Text>{ 
@SuppressWarnings("unchecked") 
public void map(LongWritable key, Text value, Context con) throws IOException, InterruptedException 

     {     
      String line = value.toString(); 
      String[] words=line.split(","); 
      for(String word: words) 
      { 
        Text outputKey = new Text(word.toUpperCase().trim()); 

       con.write(outputKey, words); 
      } 
      } 




      } 

答えて

0

、まあ今私はのためにそのプログラムを共有していますこれは私がhadoop-1.2.1 jarファイルの依存関係を書いた、それは数を変換するためだったとの言葉でそれらを記述し、これは、任意の単一のエラーなしで4つのラックス番号に加工した、

だからここにプログラムがある -

package com.whodesire.count; 

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.LongWritable; 
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.output.FileOutputFormat; 
import org.apache.hadoop.util.GenericOptionsParser; 

import com.whodesire.numstats.AmtInWords; 

public class CountInWords { 


    public static class NumberTokenizerMapper 
        extends Mapper <Object, Text, LongWritable, Text> { 

     private static final Text theOne = new Text("1"); 
     private LongWritable longWord = new LongWritable(); 

     public void map(Object key, Text value, Context context) { 

      try{ 
       StringTokenizer itr = new StringTokenizer(value.toString()); 
       while (itr.hasMoreTokens()) { 
        longWord.set(Long.parseLong(itr.nextToken())); 
        context.write(longWord, theOne); 
       } 
      }catch(ClassCastException cce){ 
       System.out.println("ClassCastException raiseddd..."); 
       System.exit(0); 
      }catch(IOException | InterruptedException ioe){ 
       ioe.printStackTrace(); 
       System.out.println("IOException | InterruptedException raiseddd..."); 
       System.exit(0); 
      } 
     } 
    } 

    public static class ModeReducerCumInWordsCounter 
      extends Reducer <LongWritable, Text, LongWritable, Text>{ 
     private Text result = new Text(); 

     //This is the user defined reducer function which is invoked for each unique key 
     public void reduce(LongWritable key, Iterable<Text> values, 
       Context context) throws IOException, InterruptedException { 

      /*** Putting the key, which is a LongWritable value, 
         putting in AmtInWords constructor as String***/ 
      AmtInWords aiw = new AmtInWords(key.toString()); 
      result.set(aiw.getInWords()); 

      //Finally the word and counting is sent to Hadoop MR and thus to target 
      context.write(key, result); 
     } 
    } 

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException { 

     /**** 
     *** all random numbers generated inside input files has been 
     *** generated using url https://andrew.hedges.name/experiments/random/ 
     ****/ 

     //Load the configuration files and add them to the the conf object 
     Configuration conf = new Configuration();  

     String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs(); 

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

     //Specify the jar which contains the required classes for the job to run. 
     job.setJarByClass(CountInWords.class); 

     job.setMapperClass(NumberTokenizerMapper.class); 
     job.setCombinerClass(ModeReducerCumInWordsCounter.class); 
     job.setReducerClass(ModeReducerCumInWordsCounter.class); 

     //Set the output key and the value class for the entire job 
     job.setMapOutputKeyClass(LongWritable.class); 
     job.setMapOutputValueClass(Text.class); 

     //Set the Input (format and location) and similarly for the output also 
     FileInputFormat.addInputPath(job, new Path(otherArgs[0])); 
     FileOutputFormat.setOutputPath(job, new Path(otherArgs[1])); 

     //Setting the Results to Single Target File 
     job.setNumReduceTasks(1); 

     //Submit the job and wait for it to complete 
     System.exit(job.waitForCompletion(true) ? 0 : 1);  
    } 

} 

あなたがエラーを見た後、あなたがプロジェクトにmapreduce jarを追加していないようだから、特にhadoop-core-xxxjarに追加したhadoop jarを見直すことをお勧めします私はそれがあなたを助けてくれることを願っています、ありがとう。

+0

私はhadoop 2.7.1を使用します。これらの3つのjarファイルhadoop-common-2.7.1、hadoop-mapreduce-client-jobclient-2.7.1、hadoop-mapreduce-client-core-2.7.1.jarを追加しました。私はそのエラーを再び覚えました。 – programer

関連する問題

 関連する問題