[ 
https://issues.apache.org/jira/browse/HADOOP-8778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13450767#comment-13450767
 ] 

Emir Ibrahimbegovic commented on HADOOP-8778:
---------------------------------------------

Thank you I filed a ticket in there. 
                
> Null pointer exception when trying to get job name by job id from jobClient
> ---------------------------------------------------------------------------
>
>                 Key: HADOOP-8778
>                 URL: https://issues.apache.org/jira/browse/HADOOP-8778
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: conf
>    Affects Versions: 0.23.1
>            Reporter: Emir Ibrahimbegovic
>
> Consider the following code :
> public static void main(String[] args) throws IOException {
>         Configuration conf = HBaseConfiguration.create();
>         conf.set("hbase.zookeeper.quorum", 
> "zk1.myhost,zk2.myhost,zk3.myhost");
>         conf.set("hbase.zookeeper.property.clientPort", "2181");
>         InetSocketAddress jobtracker = new 
> InetSocketAddress("jobtracker.mapredhost.myhost", 8021);
>         JobClient jobClient = new JobClient(jobtracker, conf);
>         JobStatus[] jobs = jobClient.jobsToComplete();
>         for (int i = 0; i < jobs.length; i++) {
>             JobStatus js = jobs[i];
>             if (js.getRunState() == JobStatus.RUNNING) {
>                 JobID jobId = js.getJobID();
>                 System.out.println(jobId);
>             }
>         }
>     }
> Code above works without errors but if you add this extra line :
> System.out.println(jobClient.getJob(jobId).getJobName());
> This exception occurs :
> Exception in thread "main" java.lang.NullPointerException
>       at 
> org.apache.hadoop.mapred.JobClient$NetworkedJob.<init>(JobClient.java:226)
>       at org.apache.hadoop.mapred.JobClient.getJob(JobClient.java:1080)
> Fix is to add set configuration to jobclient again "jobClient.setConf(conf);" 
> even if it was instantiated using InetSocketAddress and Configuration (see 
> code above).
> If you look at line 225 JobClient :
>  Configuration conf = JobClient.this.getConf();
>       this.completionPollIntervalMillis = 
> conf.getInt(COMPLETION_POLL_INTERVAL_KEY,
>           DEFAULT_COMPLETION_POLL_INTERVAL); //NPE occurs here!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to