admin管理员组

文章数量:1401627

I need to execute a java jar file from Spoon.

The program has only one class, and all I want is to run it with or without parameters.

The class is named "Limpieza", and is inside a package named:

.overflow.csv.clean

I have deploy the jar to:

C:\Program Files (x86)\Kettle\data-integration\lib

And from a Modified JavaScriptValue step, I am calling it this way:

var jar = .everis.csv.clean.Limpieza;

This is not working at all, is there a way around to make it work? Also would be nice to have a way to see the logs printed by the program when it runs. I am not getting any error when I run the transformation.

Thanks.

I need to execute a java jar file from Spoon.

The program has only one class, and all I want is to run it with or without parameters.

The class is named "Limpieza", and is inside a package named:

.overflow.csv.clean

I have deploy the jar to:

C:\Program Files (x86)\Kettle\data-integration\lib

And from a Modified JavaScriptValue step, I am calling it this way:

var jar = .everis.csv.clean.Limpieza;

This is not working at all, is there a way around to make it work? Also would be nice to have a way to see the logs printed by the program when it runs. I am not getting any error when I run the transformation.

Thanks.

Share Improve this question asked Mar 5, 2015 at 11:16 beerLanternbeerLantern 4907 silver badges24 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

Check the blog below:

https://anotherreeshu.wordpress./2015/02/07/using-external-jars-import-in-pentaho-data-integration/

Hope this might help :)

Spoon will load any jar files present in its

data-integration\lib

folder and its subfolders during startup, so if you want to access classes from a custom jar, you could place the jar here.

So you need to create a custom jar and place the jar in

data-integration\lib

location.

While calling a custom class in "Modified Java Script Value" or in "User Defined Java Class step" you should call with fully qualified name. For example
var jar = .everis.csv.clean.Limpieza.getInstance().getMyString();

Note: After placing the jar, make sure you restart the Spoon.

If still does not work please attach the Pentaho.log (data-integration-server/logs/Pentaho.log) and catalina.out(data-integration-server/tomcat/logs) logs

The answer was to create a User Defined Java Class (follow the guide Rishu pointed), and here is my working code:

import java.util.*;
import .everis.csv.Cleaner;

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
    Cleaner c = new Cleaner();
    c.clean();
    // The rest of it is for making it work
    // You will also need to make a Generate Rows step that inputs a row to this step. 
    Object[] r = getRow();

    if (r == null) {
        setOutputDone();
        return false;
    } 
    r = createOutputRow(r, data.outputRowMeta.size());
    putRow(data.outputRowMeta, r);

    return true;
}

本文标签: javaExecute jar file in Spoon (Pentaho Kettle)Stack Overflow