2013-10-28 58 views
0

我设置了一个用户定义的java类,它在特定的时间范围内为每一天生成一行。 如果我使用“Test class”来测试这个类,一切都按预期工作。 然而,当步实际上是这个过程中我碰到下面的错误中调用:初始化UserDefinedJavaClass Pentaho数据集成时出错

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! 

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

你对如何解决这个问题有什么想法吗?

回答

0

为什么processRow返回false?在返回true的示例中。

因此,您在每次处理行时都强制执行失败。

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

+0

返回false不会导致janino编译异常。返回false仅仅意味着这一步完成了处理行。并且PDI不应再次调用processRows。 –

+0

janino编译异常在哪里?没有看到。无论在上述示例中,这意味着PDI将永远不会处理任何行,并且看起来很奇怪。 – Codek

+0

它是日志中的第二行。 org.codehaus.janino.CompileException。返回false并不意味着该步骤失败,它只意味着停止处理更多行。通过调用该行的putError发生错误。 –