javapentahokettlepdispoon

Unable to find ID Kettle


I'm trying to integrate Kettle in Java and execute a Transformation. The packages are downloaded correctly. However, when I try to run the transformation as a Java Application i receive the following exception:

Unable to find plugin with ID 'Kettle'.  If this is a test, make sure kettle-core tests jar is a dependency.  If this is live make sure a kettle-password-encoder-plugins.xml exits in the classpath

    at org.pentaho.di.core.encryption.Encr.init(Encr.java:61)
    at org.pentaho.di.core.KettleClientEnvironment.init(KettleClientEnvironment.java:124)
    at org.pentaho.di.core.KettleClientEnvironment.init(KettleClientEnvironment.java:80)
    at org.pentaho.di.core.KettleEnvironment.init(KettleEnvironment.java:134)
    at org.pentaho.di.core.KettleEnvironment.init(KettleEnvironment.java:101)
    at org.pentaho.di.core.KettleEnvironment.init(KettleEnvironment.java:82)
    at com.marc.TFG.test.pentaho.EjecutarTransformaciones.main(EjecutarTransformaciones.java:13)

Files: EjecutarTransformaciones.java

package com.marc.TFG.test.pentaho;

import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.logging.LogLevel;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;

public class EjecutarTransformaciones {

    public static void main(String[] args) throws KettleException {

        KettleEnvironment.init();
        TransMeta transMeta = new TransMeta("D:\\PROYECTO_TFG\\KJB\\Prueba.ktr");
        Trans trans = new Trans(transMeta);
        trans.setLogLevel(LogLevel.BASIC);
        trans.execute(null);
        trans.waitUntilFinished();

        if(trans.getErrors() > 0){
            System.out.println("Han habido errores");
        }

    }
}

pom.xml

       <repositories>
          <repository>
              <id>pentaho-releases</id>
              <url>https://nexus.pentaho.org/content/groups/omni</url>
          </repository>
       </repositories>
        <!-- PENTAHO KETTLE DEPENDENCIES -->
        <dependency>
            <groupId>pentaho-kettle</groupId>
            <artifactId>kettle-core</artifactId>
            <version>9.1.0.0-324</version>
        </dependency>
        
        <dependency>
            <groupId>pentaho-kettle</groupId>
            <artifactId>kettle-engine</artifactId>
            <version>9.1.0.0-324</version>
        </dependency>

        <dependency>
            <groupId>pentaho-kettle</groupId>
            <artifactId>kettle-ui-swt</artifactId>
            <version>9.1.0.0-324</version>
            <scope>provided</scope>
        </dependency>
        
         <dependency>
            <groupId>pentaho-library</groupId>
            <artifactId>libformula</artifactId>
            <version>7.0.0.6-95</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging-api</artifactId>
                </exclusion>
            </exclusions>   
        </dependency>
                
        <dependency>
            <groupId>pentaho-kettle</groupId>
            <artifactId>kettle5-log4j-plugin</artifactId>
            <version>7.1.0.31-241</version>
        </dependency>

I`m running Java 8, hope there is an easy solution


Solution

  • After days of investigation, I finally found a ~solution~

    I added a new Source Folder containing the 'kettle-password-encoder-plugins.xml' file.

    UPDATE: You can easily drop the file on resources, so its included in the classpath

    Which is:

    <password-encoder-plugins>
      <password-encoder-plugin id="Kettle">
        <description>Kettle Password Encoder</description>
        <classname>org.pentaho.support.encryption.KettleTwoWayPasswordEncoder</classname>
      </password-encoder-plugin>
    </password-encoder-plugins>
    

    And it seems to work fine.

    Create a folder for this file inside your project and then, inside your IDE (in my case, Eclipse) you should see the folder you created in the Package Explorer. Then Right Click -> Build Path -> Use as Source Folder