初始化UserDefinedJavaClass Pentaho数据集成时出错

时间:2013-10-28 10:51:54

标签: java pentaho kettle

我设置了一个用户定义的java类,它在特定的时间跨度内为每一天生成一行。 如果我使用“测试类”测试类,一切都按预期工作。 但是,当在该过程中实际调用该步骤时,我得到以下错误:

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!

该类的代码如下所示:     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;
}

您对如何解决这个问题有任何想法吗?

1 个答案:

答案 0 :(得分:0)

为什么processRow返回false?在返回true的样本中..

因此,每次处理行时,您都会强制步骤失败。

如果那是故意的,你使用错误处理还是什么?你能附上转换图片和/或.ktr文件吗?