MapReduce 本地执行hadoop程序 报错 java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

java.lang.Exception: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:462)
	at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:522)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:131)
	at org.apache.hadoop.mapred.JobConf.getOutputKeyComparator(JobConf.java:884)
	at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.init(MapTask.java:981)
	at org.apache.hadoop.mapred.MapTask.createSortingCollector(MapTask.java:391)
	at org.apache.hadoop.mapred.MapTask.access$100(MapTask.java:80)
	at org.apache.hadoop.mapred.MapTask$NewOutputCollector.(MapTask.java:675)
	at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:747)
	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340)
	at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:243)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
	at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:129)
	... 13 more
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: com.likun.mr.friend.User.()
	at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:131)
	at org.apache.hadoop.io.WritableComparator.newKey(WritableComparator.java:144)
	at org.apache.hadoop.io.WritableComparator.(WritableComparator.java:130)
	at org.apache.hadoop.io.WritableComparator.(WritableComparator.java:121)
	at com.likun.mr.friend.FofSort.(FofSort.java:8)
	... 18 more
Caused by: java.lang.NoSuchMethodException: com.likun.mr.friend.User.()
	at java.lang.Class.getConstructor0(Class.java:3074)
	at java.lang.Class.getDeclaredConstructor(Class.java:2170)
	at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:125)
	... 22 more




今天写一个查找共同好友的hadoop 程序是出现了上面的错误,用百度上的什么使用jar包运行也没解决!无意中找到了,一个博主写的!

http://blog.csdn.net/zhouyan8603/article/details/50963563

当你使用自己的类实现WritableComparable接口时,必须要写上默认构造方法,加上默认的构造方法后问题解决了!




你可能感兴趣的:(MapReduce 本地执行hadoop程序 报错 java.lang.RuntimeException: java.lang.reflect.InvocationTargetException)