java - null pointer exception in getstrings method hadoop -


getting null pointer exception in driver class conf.getstrings() method. driver class invoked custom website.

below driver class details

 @suppresswarnings("unchecked") public void doget(httpservletrequest request,                  httpservletresponse response)          throws servletexception, ioexception {        configuration conf = new configuration();               //conf.set("fs.default.name", "hdfs://localhost:54310");        //conf.set("mapred.job.tracker", "localhost:54311");        //conf.set("mapred.jar","/home/htcuser/desktop/resumelatest.jar");        job job = new job(conf, "resumesearchclass");                job.setjarbyclass(helloform.class);              job.setjobname("resumeparse");        job.setinputformatclass(fileinputformat.class);        fileinputformat.addinputpath(job, new path("hdfs://localhost:54310/usr/resumedirectory"));        job.setmapperclass(resumemapper.class);        job.setreducerclass(resumereducer.class);        job.setmapoutputkeyclass(intwritable.class);        job.setsortcomparatorclass(reversecomparator.class);               job.setmapoutputvalueclass(text.class);        job.setoutputkeyclass(intwritable.class);        job.setoutputvalueclass(text.class);        job.setoutputformatclass(fileoutputformat.class);        fileoutputformat.setoutputpath(job, new path("hdfs://localhost:54310/usr/output" + system.currenttimemillis()));        long start = system.currenttimemillis();        var = job.waitforcompletion(true) ? 0 : 1; 

getting null pointer exception following 2 line of code

string[] keytextarray=conf.getstrings("keytext");     for(int i=0;i<keytextarray.length;i++) //getting null pointer exception here in keytextarray.length     {         //some code here     }         if(var==0)        {                 requestdispatcher dispatcher = request.getrequestdispatcher("/result.jsp");         dispatcher.forward(request, response);        long finish= system.currenttimemillis();        system.out.println("time taken "+(finish-start));        } } 

i have removed few unwanted codes above drives class method...

below recordwriter class use conf.setstrings() in write() method set values

below recordwriter class details

    public class recordwrite extends org.apache.hadoop.mapreduce.recordwriter<intwritable, text> {      taskattemptcontext context1;     configuration conf;      public recordwrite(dataoutputstream output, taskattemptcontext context)     {         out = output;                 conf  = context.getconfiguration();         helloform.context1=context;                 try {             out.writebytes("result:\n");             out.writebytes("name:\t\t\t\texperience\t\t\t\t\tpriority\tprioritycount\n");                     } catch (ioexception e) {             e.printstacktrace();         }     }     public recordwrite() {         // todo auto-generated constructor stub     }     @override     public void close(taskattemptcontext context) throws ioexception,             interruptedexception     {             out.close();     }     int z=0;     @override     public void write(intwritable value,text key) throws ioexception,             interruptedexception     {          conf.setstrings("keytext", key1string); //setting values here                 conf.setstrings("valtext", valuestring);         string[] keytext=key.tostring().split(pattern.quote("^"));         //some code here      } }` 

`i suspect null pointer exception happens since call conf.getstrings() method after job completed (job.waitforcompletion(true)). please fix issue.

if above code not correct way of passing values recordwriter() method driverclass.. please let me know how pass values recordwriter() driver class.

i have tried option of setting values in recordwriter() custom static class , accessing object static class in driverclass again returns null exception if running code in cluster..

if have value of key1staring , valuestirng, in job class, try setting them in job class itself, rather recordwriter.write() method.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -