通过java运行Kettle转换

时间:2014-12-23 11:39:13

标签: java pentaho kettle pdi

我创建了一个java app(pilot)来运行一个水壶转换。它非常简单,我只有主方法,获取.ktr文件并执行它。

public static void main( String[] args )
    {
        try {
            KettleEnvironment.init();
            TransMeta transMeta = new TransMeta("C:\\user\\car.ktr");
            Trans trans = new Trans(transMeta); //create new transformation object
            trans.execute(null);
            trans.waitUntilFinished();
        } catch (KettleException e) {
            e.printStackTrace();
        }
    }

问题在于,当我运行它时,我得到一个例外。

2014/12/23 08:24:54 - Table output.0 - ERROR (version 5.0.5, build 1 from 2014-03-21_17-56-23 by buildguy) : Error initializing step [Table output]
2014/12/23 08:24:54 - Table output.0 - ERROR (version 5.0.5, build 1 from 2014-03-21_17-56-23 by buildguy) : java.lang.AbstractMethodError
2014/12/23 08:24:54 - Table output.0 -  at org.pentaho.di.core.logging.LoggingObject.grabLoggingObjectInformation(LoggingObject.java:136)
2014/12/23 08:24:54 - Table output.0 -  at org.pentaho.di.core.logging.LoggingObject.<init>(LoggingObject.java:56)
2014/12/23 08:24:54 - Table output.0 -  at org.pentaho.di.core.logging.LoggingRegistry.registerLoggingSource(LoggingRegistry.java:70)
2014/12/23 08:24:54 - Table output.0 -  at org.pentaho.di.core.logging.LogChannel.<init>(LogChannel.java:74)
2014/12/23 08:24:54 - Table output.0 -  at org.pentaho.di.core.database.Database.<init>(Database.java:191)
2014/12/23 08:24:54 - Table output.0 -  at org.pentaho.di.trans.steps.tableoutput.TableOutput.init(TableOutput.java:598)
2014/12/23 08:24:54 - Table output.0 -  at org.pentaho.di.trans.step.StepInitThread.run(StepInitThread.java:65)
2014/12/23 08:24:54 - Table output.0 -  at java.lang.Thread.run(Unknown Source)
2014/12/23 08:24:54 - car - ERROR (version 5.0.5, build 1 from 2014-03-21_17-56-23 by buildguy) : Step [Table output.0] failed to initialize!
org.pentaho.di.core.exception.KettleException: 
We failed to initialize at least one step.  Execution can not begin!


    at org.pentaho.di.trans.Trans.prepareExecution(Trans.java:1068)
    at org.pentaho.di.trans.Trans.execute(Trans.java:578)
    at neoway.com.App.main(App.java:16)

它用maven创建了这个应用程序,我有这些依赖项。

   <dependency>
      <groupId>pentaho-kettle</groupId>
      <artifactId>kettle-engine</artifactId>
      <version>5.0.5</version>
   </dependency>
   <dependency>
      <groupId>pentaho-kettle</groupId>
      <artifactId>kettle-db</artifactId>
      <version>4.4.3.3</version>
   </dependency>
   <dependency>
      <groupId>pentaho-kettle</groupId>
      <artifactId>kettle-core</artifactId>
      <version>5.0.5</version>
   </dependency>
   <dependency>
      <groupId>pentaho-kettle</groupId>
      <artifactId>kettle-ui-swt</artifactId>
      <version>5.0.5</version>
   </dependency>
   <dependency>
      <groupId>pentaho-library</groupId>
      <artifactId>libformula</artifactId>
      <version>5.0.5</version>
   </dependency>

有人对这个问题有任何想法吗?

感谢。

1 个答案:

答案 0 :(得分:0)

您还需要在pom.xml文件中添加数据库依赖项。由于您的转换(您正在执行的转换)具有数据库连接,因此您需要将相应的jar导入到eclipse工作区。否则eclipse将抛出异常。

查看我的pentaho wikithis博客。我使用postgresql作为数据库连接。尝试根据您的数据库修改maven。

希望有所帮助:)