MapReduce自定义InputFormat异常:Caused by: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable

异常信息:

Caused by: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable
MapReduce自定义InputFormat异常:Caused by: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable

异常来源:

在使用MapReduce自定义InputFormat后,运行程序抛出该异常。异常抛出后,一开始认为可能是代码中涉及类型转换出现问题。反复排查后,此可能被排除

异常分析:

以下是异常发生前书写的代码:
MapReduce自定义InputFormat异常:Caused by: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable
自定义 InputFormat,需要在调用 addInputPath() 方法配置 自定义InputFormat.class

解决方案:

调用Job实例的 setInputFormatClass() 设置自定义InputFormat.class
MapReduce自定义InputFormat异常:Caused by: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable
运行通过
MapReduce自定义InputFormat异常:Caused by: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable