Search code examples
javawindowspentahokettle

Running *.ktr in Java throws KettleMissingPluginsException - Why?


I created a variety of data transformations (*.ktr files) which run perfectly when started from the Spoon GUI (PDI-CE 5.4.0.1-130; Windows 7).

I try to run them from Java with the following code (close to the example code from the documentation):

KettleClientEnvironment.init();
TransMeta metaData = new TransMeta("C:\\examplepath\\test.ktr");

Trans transformation = new Trans(metaData);
transformation.execute(null);
transformation.waitUntilFinished();
...

When executed, I get the following exception:

org.pentaho.di.core.exception.KettleMissingPluginsException: 
Missing plugins found while loading a transformation

Step : CsvInput
Step : XMLOutput
    at org.pentaho.di.trans.TransMeta.loadXML(TransMeta.java:2882)
    at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2718)
    at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2670)
    at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2647)
    at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2627)
    at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2592)
    at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2555)
    at (caller method in my code)

As I am not using any plugins but only native steps (in this example CsvInput, XMLOutput), I do not understand the reason for the thrown Exception. Why is it thrown and how can I fix the code to run?

Am I maybe missing maven dependencies? I use the following repository http://repository.pentaho.org/content/groups/omni/ and dependencies:

<dependency>
    <groupId>pentaho-kettle</groupId>
    <artifactId>kettle-core</artifactId>
    <version>5.4.0.1-130</version>
</dependency>
<dependency>
    <groupId>pentaho-kettle</groupId>
    <artifactId>kettle-engine</artifactId>
    <version>5.4.0.1-130</version>
</dependency>
<dependency>
    <groupId>pentaho-kettle</groupId>
    <artifactId>kettle-ui-swt</artifactId>
    <version>5.4.0.1-130</version>
</dependency>
<dependency>
    <groupId>pentaho-library</groupId>
    <artifactId>libformula</artifactId>
    <version>5.4.0.1-130</version>
</dependency>

Thanks a lot in advance for your answers.


Solution

  • I accidentally used KettleClientEnvironment.init() but I should have used KettleEnvironment.init(). Consequently, the environment was not properly initialized which triggered the Exception. Wow. That's a rookie mistake :)

    The corrected code, as it can also be found in the Kettle docs and Rishu's example:

    KettleEnvironment.init();
    TransMeta metaData = new TransMeta("C:\\examplepath\\test.ktr");
    
    Trans transformation = new Trans(metaData);
    transformation.execute(null);
    transformation.waitUntilFinished();
    ...
    

    Thanks lufki and Rishu for the comments and pointers.