3

I'm new to java and having some trouble running an oozie job using java code. I am unable to figure out the problem in the code. Some help will be really appreciated. Here's my code

import java.util.Properties;

import org.apache.oozie.client.OozieClient;
import org.apache.oozie.client.WorkflowJob;

public class oozie {

public static void main(String[] args) {
    OozieClient wc = new OozieClient("http://host:11000/oozie");

    Properties conf = wc.createConfiguration();

    conf.setProperty(OozieClient.APP_PATH, "hdfs://cluster/user/apps/merge-psp-logs/merge-wf/workflow.xml");
    conf.setProperty("jobTracker", "jobtracker.bigdata.com:8021");
    conf.setProperty("nameNode", "hdfs://namenode.bigdata.com:8020");
    conf.setProperty("queueName", "jobtracker.bigdata.com:8021");
    conf.setProperty("appsRoot", "hdfs://namenode.bigdata.com:8020/user/workspace/apps");
    conf.setProperty("appLibLoc", "hdfs://namenode.bigdata.com:8020/user/workspace/lib");
    conf.setProperty("rawlogsLoc", "hdfs://namenode.bigdata.com:8020/user/workspace/");
    conf.setProperty("mergedlogsLoc", "jobtracker.bigdata.com:8021");
    try {
        String jobId = wc.run(conf);
        System.out.println("Workflow job submitted");

        while (wc.getJobInfo(jobId).getStatus() == WorkflowJob.Status.RUNNING) {
            System.out.println("Workflow job running ...");
            Thread.sleep(10 * 1000);
        }
        System.out.println("Workflow job completed ...");
        System.out.println(wc.getJobInfo(jobId));
    } catch (Exception r) {
        System.out.println("Errors");
    }
}
}

Though i am able to launch the job using command line

2
  • Compilation or runtime error? Commented Oct 11, 2012 at 9:29
  • @GiulioQuaresima gives me runtime errors Commented Oct 11, 2012 at 9:32

1 Answer 1

2

Without any further information, i would say this is the probably cause of your runtime errors:

conf.setProperty(OozieClient.APP_PATH, 
    "hdfs://cluster/user/apps/merge-psp-logs/merge-wf/workflow.xml");
conf.setProperty("jobTracker", "jobtracker.bigdata.com:8021");
conf.setProperty("nameNode", "hdfs://namenode.bigdata.com:8020");
conf.setProperty("queueName", "jobtracker.bigdata.com:8021");

Unless you have two clusters, my guess is you meant the APP_PATH to point to the same HDFS instance as the one named in your nameNode property, in which case try:

conf.setProperty(OozieClient.APP_PATH, 
    "hdfs://namenode.bigdata.com:8020/user/apps/merge-psp-logs/merge-wf/workflow.xml");

You might also want to change the queueName to a real queue name (probably "default", unless jobtracker.bigdata.com:8021 is the actual name of your queue):

conf.setProperty("queueName", "default");

Aside from those observations, try and post the actual runtime error you're seeing.

Sign up to request clarification or add additional context in comments.

3 Comments

made the required changes. don't have anymore runtime errors. the console prints "Errors" as per the exception defined. any idea what might be the reason?
Seriously, this would be a lot easier if you posted the errors you're seeing
got the thing working. it was because of, firstly the changes which you asked to make and lastly, including json-simple jar in the classpath

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.