| 1 | = Debug = |
| 2 | {{{ |
| 3 | #!java |
| 4 | public class HelloHadoop { |
| 5 | |
| 6 | public class HelloMapper extends |
| 7 | Mapper<LongWritable, Text, LongWritable, Text> { |
| 8 | .... |
| 9 | } |
| 10 | |
| 11 | public class HelloReducer extends |
| 12 | Reducer<LongWritable, Text, LongWritable, Text> { |
| 13 | ... |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | public static void main(String[] args) throws IOException, |
| 18 | InterruptedException, ClassNotFoundException { |
| 19 | } |
| 20 | } |
| 21 | }}} |
| 22 | |
| 23 | 此一內部類別會引發 |
| 24 | java.lang.RuntimeException: java.lang.NoSuchMethodException: WordIndex$wordindexM.<init>() |
| 25 | |
| 26 | 問題出在 |
| 27 | |
| 28 | 宣告內部類別的 map 或 reduce 的class 前面沒有宣告 static public ,因此正確的應該如下 |
| 29 | |
| 30 | {{{ |
| 31 | #!java |
| 32 | public class HelloHadoop { |
| 33 | |
| 34 | static public class HelloMapper extends |
| 35 | Mapper<LongWritable, Text, LongWritable, Text> { |
| 36 | .... |
| 37 | } |
| 38 | |
| 39 | static public class HelloReducer extends |
| 40 | Reducer<LongWritable, Text, LongWritable, Text> { |
| 41 | ... |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | public static void main(String[] args) throws IOException, |
| 46 | InterruptedException, ClassNotFoundException { |
| 47 | } |
| 48 | } |
| 49 | }}} |