2011-08-22 4 views
7

Hadoop 0.20.2 용 사용자 정의 InputFormat을 작성 중이며 NoSuchMethodException으로 실행 중입니다. 제거 할 수 없습니다. 실행 때이 오류가 발생했습니다사용자 정의 MapReduce 입력 형식 - 생성자를 찾을 수 없습니다.

public class ConnectionInputFormat extends FileInputFormat<Text, Connection> { 

    @Override 
    public RecordReader<Text, Connection> createRecordReader(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { 
     return new ConnectionRecordReader(); 
    } 
} 

:와 내가 시작

Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodException: testingground.TestInputJob$ConnectionInputFormat.<init>() 
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:115) 
at org.apache.hadoop.mapred.JobClient.writeNewSplits(JobClient.java:882) 
at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:779) 
at org.apache.hadoop.mapreduce.Job.submit(Job.java:432) 
at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:447) 
at testingground.TestInputJob.run(TestInputJob.java:141) 
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) 
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79) 
at testingground.TestInputJob.main(TestInputJob.java:156) 
Caused by: java.lang.NoSuchMethodException: testingground.TestInputJob$ConnectionInputFormat.<init>() 
at java.lang.Class.getConstructor0(Class.java:2706) 
at java.lang.Class.getDeclaredConstructor(Class.java:1985) 
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:109) 
... 8 more 
Java Result: 1 

을 inititially 오류를 받고 온라인 조사 후, 나는 내가 제로 인수 생성자를 가지고 있지 않았다 될 줄 알았는데 그래서 하나 추가 :

public class ConnectionInputFormat extends FileInputFormat<Text, Connection> { 

    public ConnectionInputFormat() { 
     System.out.println("NetflowInputFormat Constructor"); 
    } 

    @Override 
    public RecordReader<Text, Connection> createRecordReader(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { 
     return new ConnectionRecordReader(); 
    } 
} 

중 하나가 작동하지 않았다, 그래서 객체의 수에 갔다 두 번째 생성자 추가 :

를 0
public class ConnectionInputFormat extends FileInputFormat<Text, Connection> { 

    public ConnectionInputFormat() { 
     System.out.println("NetflowInputFormat Constructor"); 
    } 

    public ConnectionInputFormat(Object... o) { 
     System.out.println("NetflowInputFormat Constructor"); 
    } 

    @Override 
    public RecordReader<Text, Connection> createRecordReader(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { 
     return new ConnectionRecordReader(); 
    } 
} 

여전히 동일한 오류가 발생하고 해결책 찾기에 실패했습니다.

전체 전류 소스 : http://pastebin.com/2XyW5ZSS

+0

생성자를 제거하면 입력 형식으로 생성자를 가질 필요가 없습니다. –

답변

7

귀하의 ConnectionInputFormat 클래스는 정적이어야한다. 비 정적 인 중첩 클래스는 모든 생성자에 암시 된 'this'를 포함합니다. 따라서 클래스가 static으로 선언되지 않는 한 인자가없는 생성자는 실제로 보이지 않는 인수를가집니다.

+2

지난 밤에 하드 디버깅을 한 후에 비슷한 결론에 도달했습니다. 생성자에게 보내지는 "this"는 부모 클래스 (TestInputJob)입니다. 그런 다음 클래스는 "this"또는 TestInputJob의 생성자에서 매개 변수의 수를 중첩 클래스 ConnectionInputFormat의 생성자에있는 매개 변수 수와 비교했습니다. 그들은 분명히 다르므로 실패했습니다. – BugsPray

+0

@BugsPray : 그게 내가 말하려고하는 것입니다. 귀하의 말씨가 좋습니다. –

관련 문제