Home Forums MapReduce MapReduce Error when i run mapreduce program.

This topic contains 2 replies, has 2 voices, and was last updated by  Aravind Yarram 8 months, 4 weeks ago.

  • Creator
    Topic
  • #46173

    Anupam Gupta
    Participant

    Dear All

    I am facing the below error . when i run mapreduce java code for analysis of my document .I have mapreduce code compiled successful and i have made jar file also.i am firing this command.
    “hadoop jar hospital.jar edu.osu.cse.ysmart.testquery1000 /user/hue/input /user/hue/output ”

    i have write the mapreduce java code for query(Select sum( column_name) from hospital where columnname=values;

    Error code are :

    13/12/24 08:25:15 INFO mapred.JobClient: map 0% reduce 0%
    13/12/24 08:25:32 INFO mapred.JobClient: Task Id : attempt_201312240604_0010_m_000000_0, Status : FAILED
    java.lang.NullPointerException
    at edu.osu.cse.ysmart.testquery1000$Map.map(testquery1000.java:42)
    at edu.osu.cse.ysmart.testquery1000$Map.map(testquery1000.java:22)
    at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:763)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:363)
    at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:396)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1232)
    at org.apache.hadoop.mapred.Child.main(Child.java:249)

    i am waiting for your valuable response.
    THanks&Regards
    Nitin

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

  • Author
    Replies
  • #46314

    Aravind Yarram
    Participant

    The exception is clear

    java.lang.NullPointerException
    at edu.osu.cse.ysmart.testquery1000$Map.map(testquery1000.java:42)

    Provide the line numbers to your code or attach the sample input file so that we can test and let you know.

    Collapse
    #46292

    Anupam Gupta
    Participant

    Hi All,

    This is our Program for whic we are getting above error……..

    package edu.osu.cse.ysmart.TestQuery;
    import java.io.IOException;
    import java.util.*;
    import java.text.*;
    import org.apache.hadoop.fs.Path;
    import org.apache.hadoop.conf.*;
    import org.apache.hadoop.io.*;
    import org.apache.hadoop.util.Tool;
    import org.apache.hadoop.util.ToolRunner;
    import org.apache.hadoop.mapreduce.Job;
    import org.apache.hadoop.mapreduce.Mapper;
    import org.apache.hadoop.mapreduce.Reducer;
    import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
    import org.apache.hadoop.mapreduce.lib.input.FileSplit;
    import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
    import org.apache.hadoop.mapreduce.lib.output.MultipleOutputs;
    import org.apache.hadoop.mapreduce.lib.partition.*;

    public class TestQuery1 extends Configured implements Tool{

    public static class Map extends Mapper<Object, Text,NullWritable,Text>{

    public void map(Object key, Text value, Context context) throws IOException,InterruptedException{

    String line = value.toString();
    String[] line_buf = new String[3];
    int prev=0,i=0,n=0;
    for(i=0,n=0,prev=0;i<line.length();i++){

    if (line.charAt(i) == ‘|’){
    line_buf[n] = line.substring(prev,i);
    n = n+1;
    prev = i+1;
    }
    if(n == 3)
    break;
    }

    if(n<3)
    line_buf[n] = line.substring(prev,i);
    if(line_buf[2].compareTo(“Abid Khan”) == 0){

    NullWritable key_op = NullWritable.get();
    context.write(key_op , new Text(line_buf[1]+ “|” ));
    }
    }

    }

    public int run(String[] args) throws Exception{

    Configuration conf = new Configuration();
    Job job = new Job(conf,”TestQuery1″);
    job.setJarByClass(TestQuery1.class);
    job.setMapOutputKeyClass(NullWritable.class);
    job.setMapOutputValueClass(Text.class);
    job.setOutputKeyClass(NullWritable.class);
    job.setOutputValueClass(Text.class);
    job.setMapperClass(Map.class);
    FileInputFormat.addInputPath(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));
    return (job.waitForCompletion(true) ? 0 : 1);
    }

    public static void main(String[] args) throws Exception {

    int res = ToolRunner.run(new Configuration(), new TestQuery1(), args);
    System.exit(res);
    }

    }

    Thanks in advance
    Nitin

    Collapse
Viewing 2 replies - 1 through 2 (of 2 total)