Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Unable to run job from java command line

  1. #1
    Join Date
    Jun 2010
    Posts
    11

    Default Unable to run job from java command line

    Hello,

    I have a job which I am able to run from java application using eclipse.

    I created a runnbale jar , but when I try to launch from commandline I am unable to do that. I am using maven for building and generating jar.

    I am getting some null pointer exception .

    following is the exception trace.

    Exception in thread "main" java.lang.NullPointerException
    at java.util.Hashtable.put(Unknown Source)
    at org.pentaho.di.core.variables.Variables.<init>(Variables.java:49)
    at org.pentaho.di.job.JobMeta.<init>(JobMeta.java:132)
    at org.pentaho.di.job.JobMeta.<init>(JobMeta.java:703)
    at com.opta.titan.Titan.runJob(Titan.java:114)
    at com.opta.titan.Titan.main(Titan.java:87)



    here is the code of My JOB


    try
    {
    StepLoader.init();
    JobEntryLoader.init();
    StepLoader stepLoader = StepLoader.getInstance();
    LogWriter logWriter =
    null;
    try {
    logWriter = LogWriter.getInstance(LogWriter.
    LOG_LEVEL_BASIC);
    }
    catch (Throwable t) {

    }

    System.
    out.println("filename----"+filename.toString());
    System.
    out.println("logWriter----"+logWriter);
    JobMeta jobMeta=
    null;

    jobMeta =
    new JobMeta(logWriter, filename, null,null);
    //jobMeta = new JobMeta(logWriter);


    //jobMeta.setInternalKettleVariables();


    System.
    out.println("jobMeta----"+jobMeta);

    jobMeta.setFilename(filename);

    Job job =
    new Job(logWriter, stepLoader, null, jobMeta);

    //System.out.println("job----"+job);


    job.getJobMeta().setArguments(
    null);
    job.initializeVariablesFrom(
    null);

    /*CONNECTION VARIABLES*/

    //source

    job.setVariable(
    "SOURCE_HOST", SOURCE_HOST);
    job.setVariable(
    "SOURCE_DB", SOURCE_DB);
    job.setVariable(
    "SOURCE_USER", SOURCE_USER);
    job.setVariable(
    "SOURCE_PWD", SOURCE_PWD);
    //destination

    job.setVariable(
    "DEST_HOST", DEST_HOST);
    job.setVariable(
    "DEST_DB", DEST_DB);
    job.setVariable(
    "DEST_USER", DEST_USER);
    job.setVariable(
    "DEST_PWD", DEST_PWD);

    job.setVariable(
    "JOB", jobType);

    //System.out.println("job variables ----"+job.getVariable("JOB"));



    /*BIS*/

    if(jobType!=null && jobType.equals("BIS")){
    job.setVariable(
    "tableName", reqParameter);
    }
    elseif (jobType!=null && jobType.equals("GDS")){
    job.setVariable(
    "GAME_ID", reqParameter);
    }
    /*
    * Maximum numer of allowed errors,
    * this striclty depends on the JOB value
    * as an Evaluation entry returning false is counted as an error.
    * as GDS/BIS check is performed by using an evaluation on =="BIS"
    * GDS always returns 1 error even when completing successfully.
    */

    int maximumAllowedErros = 0;
    if (jobType.equals("GDS")){
    maximumAllowedErros = 1;
    }


    job.getJobMeta().setInternalKettleVariables(job);
    // job.execute(); // You can pass arguments instead of null.

    Result result = job.execute();
    // Execute the selected job.

    job.endProcessing(Database.
    LOG_STATUS_END, result); // The

    // bookkeeping...

    job.waitUntilFinished();

    if (job.getErrors() > maximumAllowedErros ) {
    thrownew RuntimeException(
    "There were errors during transformation execution.");
    }




    Thanks in advance for your help.

    Regards
    Sri

  2. #2
    Join Date
    Jun 2010
    Posts
    11

    Default

    Hello,

    we solved the problem by placing the following code in source before instantiating the JobMeta. The problem is , it is unable to set some variables for BuildVersion while instantiating JobMeta so we manually added this code and it works

    with this we can avoid null values when we for the build version.


    BuildVersion.getInstance().setRevision(
    "1.1");

    BuildVersion.getInstance().setBuildDate(
    new Date().toString());

    Cheers
    Sri

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.