Gajapathy
Gajapathy

Reputation: 33

Caused by: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text

I am trying to compile the following github project https://github.com/DigitalPebble/behemoth/tree/master/uima

I get following error java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text

code has following output key and value class defined. where BehemothDocument is the custom class defined

                  job.setInputFormat(SequenceFileInputFormat.class);
                  job.setOutputFormat(SequenceFileOutputFormat.class);
                  job.setMapOutputKeyClass(Text.class);
                  job.setMapOutputValueClass(BehemothDocument.class);
                  job.setOutputKeyClass(Text.class);
                  job.setOutputValueClass(BehemothDocument.class);

Map class looks like below

public class UIMAMapper extends MapReduceBase implements
    Mapper<Text, BehemothDocument, Text, BehemothDocument> {

and Map function as follows

public void map(Text id, BehemothDocument behemoth,
OutputCollector<Text, BehemothDocument> output, Reporter reporter)

I have seen couple of Answers for the above error in stack overflow already which asking to change the Mapper key, value type which I don't want to do. I would like to know how to use the custom Class.

Please help on this . Below are Stack trace info

    java.lang.Exception: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text
    at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:354)
Caused by: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text
    at UIMAPackage.UIMAMapper.map(UIMAMapper.java:35)
    at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:50)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:430)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:366)
    at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:223)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

Upvotes: 1

Views: 2536

Answers (1)

Hiranya Deka
Hiranya Deka

Reputation: 241

Instead of Text use LongWritable as input key type for the mapper. It should work.

Upvotes: 1

Related Questions