복붙노트

[HADOOP] 하둡에서의 ClassNotFoundException

HADOOP

하둡에서의 ClassNotFoundException

내가 코드를 작성하고 하둡 맵리 듀스를 사용하면 서로 다른 길이의 문자열을 얻을 수 있습니다. 예 주어진 문자열 "ZYXCBA"길이 3. 내 코드 ( "ZYX", "YXC", "XCB", "CBA"), 길이 4 ( "ZYXC", "YXCB"길이 3의 가능한 모든 문자열을 반환해야하고, 마지막 길이 5 ( "ZYXCB" "XCBA"), "YXCBA").

지도 단계에서 나는 다음과 같은했다 :

내가 원하는 문자열의 키 = 길이

값 = 'ZYXCBA ".

그래서 매퍼 출력은

3,"ZYXCBA"
4,"ZYXCBA"
5,"ZYXCBA"

감소에서 나는 ( "ZYXCBA") 문자열을 키 3은 동일 3. 4,5 발생 길이의 모든 문자열을 얻을 수 있습니다. 결과는 ArrayList를 수집하고 있습니다.

나는 다음과 같은 명령을 사용하여 내 코드를 실행하고 있습니다 :

hduser@Ganesh:~/Documents$ hadoop jar Saishingles.jar hadoopshingles.Saishingles Behara/Shingles/input Behara/Shingles/output

아래 그림과 같이 내 코드입니다 :

package hadoopshingles;

import java.io.IOException;

import java.util.ArrayList;

import org.apache.hadoop.fs.Path; 

import org.apache.hadoop.io.IntWritable;

import org.apache.hadoop.io.Text;

import org.apache.hadoop.mapreduce.Mapper;

import org.apache.hadoop.mapreduce.Reducer;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.mapreduce.Job;

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;


public class Saishingles{

public static class shinglesmapper extends Mapper<Object, Text, IntWritable, Text>{

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

            String str = new String(value.toString());
            String[] list = str.split(" ");
            int index = Integer.parseInt(list[0]);
            String val = list[1];
            int length = val.length();
            for(int i = index; i <= length; i++)
            {
                context.write(new IntWritable(index),new Text(val));
            }       
        }

     }


public static class shinglesreducer extends Reducer<IntWritable,Text,IntWritable,ArrayList<String>> {
    private ArrayList<String> result = new ArrayList<String>();

    public void reduce(IntWritable key, Text value, Context context
            ) throws IOException, InterruptedException {
        String str = new String(value.toString());
        int newkey = key.get();
        int Tz = str.length() - newkey + 1;
        int position = 0;
        while (position <= Tz)
        {
            result.add(str.substring(position,position + newkey -1));
            position = position + 1;
        }   
        context.write(new IntWritable(newkey),result);
    }
}





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

      Configuration conf = new Configuration();
      Job job = Job.getInstance(conf, "Saishingles");
      job.setJarByClass(hadoopshingles.Saishingles.class);
      job.setMapperClass(shinglesmapper.class);
      job.setCombinerClass(shinglesreducer.class);
      job.setReducerClass(shinglesreducer.class);
      job.setMapOutputKeyClass(IntWritable.class);
      job.setMapOutputValueClass(Text.class);
      job.setOutputKeyClass(IntWritable.class);
      job.setOutputValueClass(ArrayList.class);
      FileInputFormat.addInputPath(job, new Path(args[0]));
      FileOutputFormat.setOutputPath(job, new Path(args[1]));
      System.exit(job.waitForCompletion(true) ? 0 : 1);

}

}

그것은 다음과 같은 오류를주고 :

Exception in thread "main" java.lang.ClassNotFoundException: hadoopshingles.Saishingles
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:278)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:214)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)

도와 사전에 감사하시기 바랍니다 :)

해결법

  1. ==============================

    1.난 당신이 클래스 이름에 "의 .class"를 포함해서는 안 믿습니다.

    난 당신이 클래스 이름에 "의 .class"를 포함해서는 안 믿습니다.

    대신에

    그것은해야한다

  2. from https://stackoverflow.com/questions/38478737/classnotfoundexception-in-hadoop by cc-by-sa and MIT license