Wednesday, April 6, 2011

Hadoop, java.lang.ClassCastException: cannot be cast to

If you work on a Mapper which expects the file format of keyvalue, and forget to specify the inputformat to jobconf, you will get the following errors.

java.lang.ClassCastException: cannot be cast to
at org.apache.hadoop.mapred.MapTask.runOldMapper(
at org.apache.hadoop.mapred.Child.main(

here is why,

for the jobconf, the default inputformat is TextInputFormat,

you will get Key/value type of longwritable/text in your Map function.
if you put something like Text as the key, you will get the classcast exception

public void map(Text key, Text value,
OutputCollector<Text, Text> collector,
Reporter paramReporter) throws IOException {

So always remember to specify the InputFormat.

No comments:

Locations of visitors to this page