2012-10-26 5 views
1

제발 도와주세요. 다음은 작업을 실행하는 코드입니다.hadoop -libjars 및 ClassNotFoundException

hadoop jar mrjob.jar ru.package.Main -files hdfs://0.0.0.0:8020/MyCatalog/jars/metadata.csv -libjars hdfs://0.0.0.0:8020/MyCatalog/jars/opencsv.jar,hdfs://0.0.0.0:8020/MyCatalog/jars/gson.jar,hdfs://0.0.0.0:8020/MyCatalog/jars/my-utils.jar /MyCatalog/http_requests.seq-r-00000 /MyCatalog/output/result_file 

나는 이것들을 얻는다는 경고 : 다음

12/10/26 18:35:50 WARN util.GenericOptionsParser: The libjars file hdfs://0.0.0.0:8020/MyCatalog/jars/opencsv.jar is not on the local filesystem. Ignoring. 
12/10/26 18:35:50 WARN util.GenericOptionsParser: The libjars file hdfs://0.0.0.0:8020/MyCatalog/jars/gson.jar is not on the local filesystem. Ignoring. 
12/10/26 18:35:50 WARN util.GenericOptionsParser: The libjars file hdfs://0.0.0.0:8020/MyCatalog/jars/my-utils.jar is not on the local filesystem. Ignoring. 

: 스레드 예외 "기본"java.lang.NoClassDefFoundError가 : 나는 단지에서 클래스를 인스턴스화하려고 Main 클래스 라인에 내-utils.jar 이름

  1. 이 모든 항아리 (I 파일 브라우저를 통해 참조) hfds에
  2. ,536,913,632 10
  3. 내-utils.jar는 NoClassDefFoundError를 내가 잘못합니까 무엇

이유입니다 클래스를 포함합니까?

UPD : 내가 의 GenericOptionsParser 소스 코드를 검사하고 있습니다 : 그래서

/** 
    * If libjars are set in the conf, parse the libjars. 
    * @param conf 
    * @return libjar urls 
    * @throws IOException 
    */ 
    public static URL[] getLibJars(Configuration conf) throws IOException { 
    String jars = conf.get("tmpjars"); 
    if(jars==null) { 
     return null; 
    } 
    String[] files = jars.split(","); 
    List<URL> cp = new ArrayList<URL>(); 
    for (String file : files) { 
     Path tmp = new Path(file); 
     if (tmp.getFileSystem(conf).equals(FileSystem.getLocal(conf))) { 
     cp.add(FileSystem.getLocal(conf).pathToFile(tmp).toURI().toURL()); 
     } else { 
     LOG.warn("The libjars file " + tmp + " is not on the local " + 
      "filesystem. Ignoring."); 
     } 
    } 
    return cp.toArray(new URL[0]); 
    } 

: 쉼표 2. 사이 1. 공백은 여전히 ​​그것을 얻을하지 않습니다 ... 나는했습니다 로컬 파일 시스템, hdfs 파일 시스템, 결과는 동일합니다. 클래스가 추가되지 않은 것 같습니다 ...

+0

자세한 대답은 여기에 게시 : http://stackoverflow.com/questions/6890087/problem-with-libjars-in-hadoop –

답변

1

단지 HDFS에 있기 때문에 실행중인 작업의 클래스 경로에있는 것은 아닙니다.

이 문제를 해결하려면 maven을 사용하여 하나의 jar 파일에 모든 종속성을 포함하는 "fat jar"를 빌드하십시오. shade plugin을 사용하여이 작업을 수행 할 수 있습니다.

하지만 명령을 보면 틀 렸습니다. -libjars, described here과 함께 "job"명령을 사용하는 것이 더 나을 것 같아요. "hadoop jar"명령을 사용하여 외부 jar를 지정할 수 있는지 확신 할 수 없습니다.

+0

나는 당신과 동의 할 수 없다. http://blog.cloudera.com/blog/2011/01/how-to-include-third-party-libraries-in-your-map-reduce-job/ 100 % 이전에 작동했습니다. 그런 다음 리팩터링을 시작했습니다 ... 또는 내가 상처를 입었습니다. 또는 Cloudera에 버그가 있습니다. 4 – Sergey

+0

: 0.19부터 -libjars를 사용하여 추가 한 병은 클라이언트에서 사용할 수 있습니다. classpath, HADOOP-3570에 의해 수정되었습니다. – Sergey

+0

이 오류는 항아리가 컴파일 할 때 나타나고 런타임에 나타나지 않을 때 거의 항상 발생합니다. 그것은 거의 확실히 classpath 문제입니다. –

4

문제가 해결되었습니다. 올바른 호출은 다음과 같습니다

/MyCatalog

는 HDFS 경로입니다

hadoop jar my-job.jar ru.package.Main -files /home/cloudera/uploaded_jars/metadata.csv -libjars /home/cloudera/uploaded_jars/opencsv.jar,/home/cloudera/uploaded_jars/gson.jar,/home/cloudera/uploaded_jars/url-raiting-utils.jar /MyCatalog/http_requests.seq-r-00000 /MyCatalog/output/scoring_result 

,

/home/cloudera/uploaded_jars/

지역 FS 경로 문제는 작업 항아리에 있었다이다. 이전에 Mapper, Reducer, Main 클래스의 세 가지 클래스 만 사용하여 간단한 jar 을 사용하여 작업을 실행하려고했습니다. 이제 maven이 생성 한 다른 파일을 제공했습니다 (두 파일을 생성했습니다). 두 번째 작업 jar는 모든 종속성 라이브러리을 포함합니다. 그 안에. 구조는 다음과 같습니다. my-job.LIB

- -

항아리 aopalliance-1.0.jar의 ASM-3.2.jar 브로-1.5.4.jar ... 평민 - beanutils을-1.7.0.jar 평민 - beanutils- core-1.8.0.jar ... 동물원 3.4.3-cdh4.0.0.jar

lib 폴더에는 76 개의 jar 파일이 있습니다.

작동하지만 이해가 안됩니다.