Question

I set up a user defined java class that generates a row for each day within a certain timespan. If I test the class using "Test class" everything works as expected. However, when the step is actually called within the process I get the following error:

013/10/28 11:45:00 - Generate Dates.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : Error initializing UserDefinedJavaClass:
2013/10/28 11:45:00 - Generate Dates.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : org.codehaus.janino.CompileException
2013/10/28 11:45:00 - Generate Dates.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : Error initializing step [Generate Dates]
2013/10/28 11:45:00 - Table output.0 - Connected to database [MSSQL Eric] (commit=1000)
2013/10/28 11:45:00 - Eingabe_Currencies - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : Step [Generate Dates.0] failed to initialize!
2013/10/28 11:45:00 - Spoon - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : Eingabe_Currencies: preparing transformation execution failed
2013/10/28 11:45:00 - Spoon - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : org.pentaho.di.core.exception.KettleException: 
2013/10/28 11:45:00 - Spoon - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : We failed to initialize at least one step.  Execution can not begin!
2013/10/28 11:45:00 - Spoon - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : 
2013/10/28 11:45:00 - Spoon - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : 
2013/10/28 11:45:00 - Spoon - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) :  at org.pentaho.di.trans.Trans.prepareExecution(Trans.java:932)
2013/10/28 11:45:00 - Spoon - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) :  at org.pentaho.di.ui.spoon.trans.TransGraph$22.run(TransGraph.java:3652)
2013/10/28 11:45:00 - Spoon - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) :  at java.lang.Thread.run(Thread.java:724)
2013/10/28 11:45:00 - Eingabe_Currencies - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : Errors detected!
2013/10/28 11:45:00 - Eingabe_Currencies - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : Errors detected!

The code for the class looks like this: import java.util.Date; import java.util.Calendar; import java.text.SimpleDateFormat;

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
    Object[] r = getRow();
    if (r == null) {
        setOutputDone();
        return false;
    }

    Calendar calStart;

    calStart = Calendar.getInstance();
    calStart.set(Calendar.YEAR, 2013);
    calStart.set(Calendar.MONTH, 0);
    calStart.set(Calendar.DAY_OF_MONTH, 1);

    Calendar calEnd;
    calEnd = Calendar.getInstance();

    SimpleDateFormat sdfDatum=new SimpleDateFormat("yyyy-MM-dd");

    Calendar cal =  Calendar.getInstance();

    for(cal.setTime(calStart.getTime());cal.before(calEnd); cal.add(Calendar.DATE, 1))
    {
        r = createOutputRow(r, data.outputRowMeta.size());  
        try{        
        get(Fields.Out, "date").setValue(r, sdfDatum.format(cal.getTime()));}
        catch(Exception e) {}
        putRow(data.outputRowMeta, r);
    }
    setOutputDone();

    return false;
}

Do you have any ideas on how to solve that problem?

Was it helpful?

Solution

Why is processRow returning false? In the samples that returns true..

So you're forcing your step to fail every time it processes a row.

If thats intentional, are you using error handling or something? Can you attach a picture of the transformation and/or the .ktr file?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top