You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Harsh J (JIRA)" <ji...@apache.org> on 2012/09/07 17:12:08 UTC

[jira] [Commented] (HADOOP-8778) Null pointer exception when trying to get job name by job id from jobClient

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

Harsh J commented on HADOOP-8778:
---------------------------------

What version of Hadoop are you running into this error on? It is not 0.23.1 as you have marked here, since http://svn.apache.org/viewvc/hadoop/common/tags/release-0.23.1/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobClient.java?view=markup does not show line 226 as a match with the stack trace.
                
> 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