我设置了一个用户定义的 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; 导入 java.util.Calendar;导入 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;
}
您对如何解决该问题有任何想法吗?