我正在尝试创建一个与其他几个作业链接的 Hadoop 作业,使其看起来像 Map1 -> Reduce -> Map2 -> Reduce。我所有的类都在同一个文件中实现。我在第一份工作中遇到以下错误。
java.lang.RuntimeException: Error in configuring object
at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:93)
at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:64)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117)
at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:354)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:307)
at org.apache.hadoop.mapred.Child.main(Child.java:170)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:88)
... 5 more
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: work.graph.WorkGraph$Map1.<init>()
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:115)
at org.apache.hadoop.mapred.MapRunner.configure(MapRunner.java:34)
... 10 more
Caused by: java.lang.NoSuchMethodException: work.graph.WorkGraph$Map1.<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)
我查看了Hadoop: No such Method Exception already,但这并没有解决我的问题。有谁知道这个错误出现的其他原因?
编辑:我的代码如下所示:
public class WorkGraph {
public static Hashmap dictionary = new Hashmap();
public static class Map1 extends MapReduceBase implements Mapper {
public void map {}
}
public static class Map2 extends MapReduceBase implements Mapper {
}
public static void main(String[] args) throws Exception {
JobConf job1 = new JobConf(WorkGraph.class);
job1.setJobName("WorkGraph1");
job1.setInputFormat(TextInputFormat.class);
job1.setOutputFormat(TextOutputFormat.class);
job1.setOutputKeyClass(Text.class);
job1.setOutputValueClass(Text.class);
job1.setMapperClass(Map1.class);
FileInputFormat.addInputPath(job1, new Path(args[0]));
FileOutputFormat.setOutputPath(job1, new Path(args[1] + "/map1"));
JobClient.runJob(job1);
}