1. 程式人生 > >執行mapreduce 程式報錯 NoSuchMethodException

執行mapreduce 程式報錯 NoSuchMethodException

把hbase資料匯入到hdfs  在執行mapreduce 程式報錯!!

報錯如下:

Error: java.lang.RuntimeException: java.lang.NoSuchMethodException: com.hadoop3.hbaseapi.day03.Demo02_HbasseToHdfs$ToHdfsMapper.<init>()
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:131)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:722)

at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1614)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163)
Caused by: java.lang.NoSuchMethodException: com.hadoop3.hbaseapi.day03.Demo02_HbasseToHdfs$ToHdfsMapper.<init>()
at java.lang.Class.getConstructor0(Class.java:2892)
at java.lang.Class.getDeclaredConstructor(Class.java:2058)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:125)
... 7 more


解決辦法:
1.如果自定義writable的時候需要注意,反射過程中需要呼叫無參構造方法,所以只要在自定義的writable類中加入預設的建構函式即可
2.Map和Reduce類須設定為Static許可權修飾!


使用方法2 解決的!