The Hortonworks Community Connection is now live. A completely rebuilt Q&A forum, Knowledge Base, Code Hub and more, backed by the experts in the industry.

You will be redirected here in 10 seconds. If your are not redirected, click here to visit the new site.

The legacy Hortonworks Forum is now closed. You can view a read-only version of the former site by clicking here. The site will be taken offline on January 31,2016

MapReduce Forum

MapReduce Error when i run mapreduce program.

  • #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

  • Author
    Replies
  • #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

    #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.

The forum ‘MapReduce’ is closed to new topics and replies.

Support from the Experts

A HDP Support Subscription connects you experts with deep experience running Apache Hadoop in production, at-scale on the most demanding workloads.

Enterprise Support »

Become HDP Certified

Real world training designed by the core architects of Hadoop. Scenario-based training courses are available in-classroom or online from anywhere in the world

Training »

Hortonworks Data Platform
The Hortonworks Data Platform is a 100% open source distribution of Apache Hadoop that is truly enterprise grade having been built, tested and hardened with enterprise rigor.
Get started with Sandbox
Hortonworks Sandbox is a self-contained virtual machine with Apache Hadoop pre-configured alongside a set of hands-on, step-by-step Hadoop tutorials.
Modern Data Architecture
Tackle the challenges of big data. Hadoop integrates with existing EDW, RDBMS and MPP systems to deliver lower cost, higher capacity infrastructure.