2016-07-21 3 views
0

を.hdfs.inverted
は、誰もがコードの修正例外は、コマンド</p> <pre><code>hadoop jar /home/edureka/Desktop/invertedindex.jar hdfs:/hdfs/inverted hdfs:/hdfs/invertedout </code></pre> <p>私は以下のエラーを取得しています実行中

で私を助けることができますスレッド "メイン" にjava.lang.ClassNotFoundExceptionで

例外:HDFSは:java.net.URLClassLoader $ 1.runでjava.net.URLClassLoader $ 1.runで (URLClassLoader.java:366) を.hdfs.inverted (URLClassLoader.java:355) at java.security.AccessController.doPrivileged(ネイティブメソッド) java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang .ClassLoader.loadClass(ClassLoader.java:358) 、java.lang.Class.forName0(ネイティブメソッド) 、java.lang.Class.forName(Class.java:270) 、org.apache.hadoop.util。 RunJar.main(RunJar.java:205)

私はすべての前提条件を試しましたが、まだ問題に直面していました。以下はenter code here

コードです:

import java.io.IOException; 
import java.util.HashMap; 

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.lib.input.FileInputFormat; 
import org.apache.hadoop.mapreduce.lib.input.FileSplit; 
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat; 
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; 
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; 
import org.apache.hadoop.mapreduce.Reducer; 

public class InvertedIndex { 

    public static class Map extends Mapper<LongWritable,Text,Text,Text> { 


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

      String fileName = ((FileSplit) context.getInputSplit()).getPath().getName(); 
      String line=value.toString(); 
      String words[]=line.split(" "); 
      for(String s:words){ 
       context.write(new Text(s), new Text(fileName)); 
      } 


     } 
    } 

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



     @Override 
     public void reduce(Text key, Iterable<Text> values, Context context) 
     throws IOException, InterruptedException { 
     HashMap m=new HashMap(); 
     int count=0; 
      for(Text t:values){ 
       String str=t.toString(); 
       if(m!=null &&m.get(str)!=null){ 
        count=(int)m.get(str); 
        m.put(str, ++count); 
       }else{`enter code here` 
        m.put(str, 1);  
       } 
      } 
      context.write(key, new Text(m.toString())); 
     } 
    } 


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

     Configuration conf= new Configuration(); 

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


     //Defining the output value class for the mapper 
     job.setMapOutputKeyClass(Text.class); 
     job.setMapOutputValueClass(Text.class); 
     job.setJarByClass(InvertedIndex.class); 
     job.setMapperClass(Map.class); 
     job.setReducerClass(Reduce.class); 

     //Defining the output value class for the mapper 
     job.setOutputKeyClass(Text.class); 
     job.setOutputValueClass(Text.class); 
     job.setInputFormatClass(TextInputFormat.class); 
     job.setOutputFormatClass(TextOutputFormat.class); 

     Path outputPath = new Path(args[1]); 

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

      //deleting the output path automatically from hdfs so that we don't have delete it explicitly 

     outputPath.getFileSystem(conf).delete(outputPath); 

      //exiting the job only if the flag value becomes false 

     System.exit(job.waitForCompletion(true) ? 0 : 1); 
    } 
} 

答えて

0

あなたはドキュメントに記載さのHadoop jarコマンドでメインクラスを渡す必要があります。

あなたのコマンド

Hadoopのジャー/home/edureka/Desktop/invertedindex.jarのHDFS:/ HDFS /反転 HDFS:/ HDFS/

invertedoutはする必要があります

hadoop jar /home/edureka/Desktop/invertedindex.jar InvertedIndex hdfs:/ hdfs/inverted hdfs:/ hdfs/invertedout

また

job.setJarByClass(InvertedIndex.class)。

job.setJarByClass(転置インデックス)であるべきです。

代わりに

私はちょうど同様の議論を持っていましたhere

+0

ありがとうございます!それは今働いています。私は、それが含まれていない理由は、クラスの指定がないいくつかの例を見てきました。それは間違ったタイプミスかもしれません。とにかく迅速な対応のために多くのおかげで。 –

+0

それはあなたのために働いてうれしい。これを解決済みとマークできれば幸いです。 – Amit

0

Hadoopのコマンドは、右のjar引数の後に合格している実行するクラスを知っている必要があります: - :

hadoop jar /home/edureka/Desktop/invertedindex.jar InvertedIndex hdfs:/hdfs/inverted hdfs:/hdfs/invertedout 

ジョブ構成がよさそうだ

Usage: hadoop jar <jar> [mainClass] args...としてsee manual

ので、あなたはjarファイルを実行する必要があります。 job.setJarbyClassに変更を加えないでください:see Class-Job

関連する問題

 関連する問題