hadoop java.lang.RuntimeException: java.lang.NoSuchMethodException

在写MR的时候遇到一个类似下面的错误信息:

java.lang.RuntimeException: java.lang.NoSuchMethodException: com.xxx.thriftoutput.RecommendResult.<init>()
        at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:131)
        at org.apache.hadoop.fs.shell.Display$TextRecordInputStream.<init>(Display.java:226)
        at org.apache.hadoop.fs.shell.Display$Text.getInputStream(Display.java:152)
        at org.apache.hadoop.fs.shell.Display$Cat.processPath(Display.java:101)
        at org.apache.hadoop.fs.shell.Command.processPaths(Command.java:306)
        at org.apache.hadoop.fs.shell.Command.processPathArgument(Command.java:278)
        at org.apache.hadoop.fs.shell.Command.processArgument(Command.java:260)
        at org.apache.hadoop.fs.shell.Command.processArguments(Command.java:244)
        at org.apache.hadoop.fs.shell.Command.processRawArguments(Command.java:190)
        at org.apache.hadoop.fs.shell.Command.run(Command.java:154)
        at org.apache.hadoop.fs.FsShell.run(FsShell.java:287)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84)
        at org.apache.hadoop.fs.FsShell.main(FsShell.java:340)
Caused by: java.lang.NoSuchMethodException: com.xxx.thriftoutput.RecommendResult.<init>()
        at java.lang.Class.getConstructor0(Class.java:2810)
        at java.lang.Class.getDeclaredConstructor(Class.java:2053)
        at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:125)
        ... 13 more

由报错信息可知应该与RecommendResult有关,而这个类是我自定义的Writable类,根据init方式和reflection可知,是与其初始化有关,后来查资料可知,在自定义writable的时候需要注意,反射过程中需要调用无参构造方法,所以只要在自定义的writable类中加入默认的构造函数即可

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值