2
votes

I have simple Job (named A) which starts a simple transformation (named A). The transformation contains only a dummy component. They are both stored into a db repository.

If I start the job from kitchen, everything runs fine:

./kitchen.sh -rep=spoon -user=<user> -pass=<pwd> -job A

Then I have written a simple java code:

JobMeta jobMeta = repository.loadJob(jobName, directory, null, null);
org.pentaho.di.job.Job job = new org.pentaho.di.job.Job(null, jobMeta);
job.getJobMeta().setInternalKettleVariables(job);
job.setLogLevel(LogLevel.ERROR);
job.setName(Thread.currentThread().getName());

job.start();
job.waitUntilFinished();

if (job.getResult() != null && job.getResult().getNrErrors() != 0) {
   ...
}
else {
   ...
}

Problem is that running the java program I always get the following error:

A - Unable to open transformation: null
A - java.lang.NullPointerException
at org.pentaho.di.job.entries.trans.JobEntryTrans.execute(JobEntryTrans.java:698)
at org.pentaho.di.job.Job.execute(Job.java:589)
at org.pentaho.di.job.Job.execute(Job.java:728)
at org.pentaho.di.job.Job.execute(Job.java:443)
at org.pentaho.di.job.Job.run(Job.java:363)

I have googled for this error without success and I am stucking there.

Any suggestion ?

1

1 Answers

0
votes

The solution seems to be replacing the line

org.pentaho.di.job.Job job = new org.pentaho.di.job.Job(null, jobMeta);

with

org.pentaho.di.job.Job job = new org.pentaho.di.job.Job(repository, jobMeta);

Hoping that this helps someone else.