'Pentaho API - Cannot resolve paths to transformations in job?

I have a job I've built in Pentaho 9.1 that contains many transformations. All of my .kjb and .ktr files are in a local file repository, and have been exported to an enterprise repository on a server. I can execute the job on the server without any issue by logging on to the server and adding the job to the scheduler in the pentaho user console, and by connecting to the repository in my local PDI client and choosing the server's run configuration. However, the job breaks when I try to execute it via the runJob/ endpoint in the API. At first, the job appears to start out fine, but as soon as it gets to the first transformation, I get this error:

Opening transformation: [null] in directory [<directory>]
ERROR : Unable to run job <jobName>. The transformation has an error. The transformation path <path to transformation> is invalid, and will not run successfully.
ERROR : org.pentaho.di.core.exception.KettleXMLException

The path to this transformation only causes a problem when I'm trying to execute the job via the pentaho API. No other method of running the job on the server produces this result. I've tried creating a new run configuration for the transformations as well as configuring the enterprise repository but with no success yet. the enterprise repository is currently configured on the default settings. Has anyone else experienced this issue? For the project I'm working on I need to be able to run the job via the API and I'm not sure what to try or really where to find good documentation on the subject.



Solution 1:[1]

You can use the environment variable ${Internal.Job.Filename.Directory} or ${Internal.Transformation.Filename.Directory} to get the current job or transformation directory.

For example, get a transformation using ${Internal.Job.Filename.Directory}/your_transformation.ktr

Check the Internal Variables documentation for more variables that could be helpful.

You could also use the Shell job entry or Get System Info step to run a command line argument and get directories data.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1