kettle-java代码执行hive相关ktr时报错: database type with plugin id [HIVE2] couldn't be found!

kettle-java代码执行hive相关ktr时报错: database type with plugin id [HIVE2] couldn't be found!

2018年08月13日 16:47:30 lisery1993 阅读数:305

1.在java项目中执行hive相关的ktr:

  1.  
  2. KettleEnvironment.init();

  3.  
  4. TransMeta transMeta = new TransMeta("C:\\Users\\lixiang\\Desktop\\hivetorizhi.ktr");

  5. // 设置执行模式

  6. TransExecutionConfiguration config = new TransExecutionConfiguration();

  7. config.setExecutingClustered(true);

  8. config.setExecutingLocally(false);

  9. config.setExecutingRemotely(false);

  10. config.setClusterPosting(true);

  11. config.setClusterPreparing(true);

  12. config.setClusterStarting(true);

  13. TransSplitter transSplitter = Trans.executeClustered(transMeta, config);

  14. System.out.println(transSplitter.getCarteObjectMap());

  15. System.out.println(transSplitter.getMaster());

  16. System.out.println(transSplitter.getSlaves()[0]);

  17. System.out.println(transSplitter.getSlaves()[1].getStepNames()[0]);

  18. }

2.报错:

 
  1. Exception in thread "main" org.pentaho.di.core.exception.KettleXMLException:

  2. 错误从XML文件读取转换

  3.  
  4. 错误从XML文件读取转换

  5.  
  6. Unable to load database connection info from XML node

  7.  
  8. Unable to create new database interface

  9.  
  10. database type with plugin id [HIVE2] couldn't be found!

  11.  
  12. at org.pentaho.di.trans.TransMeta.loadXML(TransMeta.java:3402)

  13. at org.pentaho.di.trans.TransMeta.(TransMeta.java:2758)

  14. at org.pentaho.di.trans.TransMeta.(TransMeta.java:2710)

  15. at org.pentaho.di.trans.TransMeta.(TransMeta.java:2687)

  16. at org.pentaho.di.trans.TransMeta.(TransMeta.java:2667)

  17. at org.pentaho.di.trans.TransMeta.(TransMeta.java:2632)

  18. at org.pentaho.di.trans.TransMeta.(TransMeta.java:2595)

  19. at com.kettle.KettleExamle.getRemoteServer(KettleExamle.java:55)

  20. at com.kettle.KettleExamle.main(KettleExamle.java:140)

  21. Caused by: org.pentaho.di.core.exception.KettleXMLException:

  22. 错误从XML文件读取转换

  23.  
  24. Unable to load database connection info from XML node

  25.  
  26. Unable to create new database interface

  27.  
  28. database type with plugin id [HIVE2] couldn't be found!

  29.  
  30. at org.pentaho.di.trans.TransMeta.loadXML(TransMeta.java:3384)

  31. ... 8 more

  32. Caused by: org.pentaho.di.core.exception.KettleXMLException:

  33. Unable to load database connection info from XML node

  34.  
  35. Unable to create new database interface

  36.  
  37. database type with plugin id [HIVE2] couldn't be found!

  38.  
  39. at org.pentaho.di.core.database.DatabaseMeta.(DatabaseMeta.java:1013)

  40. at org.pentaho.di.trans.TransMeta.loadXML(TransMeta.java:2976)

  41. ... 8 more

  42. Caused by: org.pentaho.di.core.exception.KettleXMLException:

  43. Unable to create new database interface

  44.  
  45. database type with plugin id [HIVE2] couldn't be found!

  46.  
  47. at org.pentaho.di.core.database.DatabaseMeta.(DatabaseMeta.java:977)

  48. ... 9 more

  49. Caused by: org.pentaho.di.core.exception.KettleDatabaseException:

  50. database type with plugin id [HIVE2] couldn't be found!

  51.  
  52. at org.pentaho.di.core.database.DatabaseMeta.findDatabaseInterface(DatabaseMeta.java:584)

  53. at org.pentaho.di.core.database.DatabaseMeta.getDatabaseInterface(DatabaseMeta.java:558)

  54. at org.pentaho.di.core.database.DatabaseMeta.(DatabaseMeta.java:974)

  55. ... 9 more

3.报错分析:kettle程序在读取database type的过程中读不到hive2这个类型。

查看kettle-core-7.1.0.0-12.jar中的kettle-database-types.xml文件,此文件定义了database type ,其中没hive2.。

 
  1.  
  2. AS/400

  3. org.pentaho.di.core.database.AS400DatabaseMeta

  4.  
  5. Intersystems Cache

  6. org.pentaho.di.core.database.CacheDatabaseMeta

  7.  
  8. IBM DB2

  9. org.pentaho.di.core.database.DB2DatabaseMeta

  10.  
  11. dBase III, IV or 5

  12. org.pentaho.di.core.database.DbaseDatabaseMeta

  13.  
  14. Apache Derby

  15. org.pentaho.di.core.database.DerbyDatabaseMeta

  16.  
  17. Exasol 4

  18. org.pentaho.di.core.database.Exasol4DatabaseMeta

  19.  
  20. ExtenDB

  21. org.pentaho.di.core.database.ExtenDBDatabaseMeta

  22.  
  23. Firebird SQL

  24. org.pentaho.di.core.database.FirebirdDatabaseMeta

  25.  
  26. Generic database

  27. org.pentaho.di.core.database.GenericDatabaseMeta

  28.  
  29. Greenplum

  30. org.pentaho.di.core.database.GreenplumDatabaseMeta

  31.  
  32. Calpont InfiniDB

  33. org.pentaho.di.core.database.InfiniDbDatabaseMeta

  34.  
  35. Gupta SQL Base

  36. org.pentaho.di.core.database.GuptaDatabaseMeta

  37.  
  38. H2

  39. org.pentaho.di.core.database.H2DatabaseMeta

  40.  
  41. Hypersonic

  42. org.pentaho.di.core.database.HypersonicDatabaseMeta

  43.  
  44. Infobright

  45. org.pentaho.di.core.database.InfobrightDatabaseMeta

  46.  
  47. Informix

  48. org.pentaho.di.core.database.InformixDatabaseMeta

  49.  
  50. Ingres

  51. org.pentaho.di.core.database.IngresDatabaseMeta

  52.  
  53. Ingres VectorWise

  54. org.pentaho.di.core.database.VectorWiseDatabaseMeta

  55.  
  56. Borland Interbase

  57. org.pentaho.di.core.database.InterbaseDatabaseMeta

  58.  
  59. KingbaseES

  60. org.pentaho.di.core.database.KingbaseESDatabaseMeta

  61.  
  62. LucidDB

  63. org.pentaho.di.core.database.LucidDBDatabaseMeta

  64.  
  65. MariaDB

  66. org.pentaho.di.core.database.MariaDBDatabaseMeta

  67.  
  68. MonetDB

  69. org.pentaho.di.core.database.MonetDBDatabaseMeta

  70.  
  71. MS Access

  72. org.pentaho.di.core.database.MSAccessDatabaseMeta

  73.  
  74. MS SQL Server (Native)

  75. org.pentaho.di.core.database.MSSQLServerNativeDatabaseMeta

  76.  
  77. MS SQL Server

  78. org.pentaho.di.core.database.MSSQLServerDatabaseMeta

  79.  
  80. MySQL

  81. org.pentaho.di.core.database.MySQLDatabaseMeta

  82.  
  83. Native Mondrian

  84. org.pentaho.di.core.database.MondrianNativeDatabaseMeta

  85.  
  86. Neoview

  87. org.pentaho.di.core.database.NeoviewDatabaseMeta

  88.  
  89. Netezza

  90. org.pentaho.di.core.database.NetezzaDatabaseMeta

  91.  
  92. Oracle

  93. org.pentaho.di.core.database.OracleDatabaseMeta

  94.  
  95. Oracle RDB

  96. org.pentaho.di.core.database.OracleRDBDatabaseMeta

  97.  
  98. PostgreSQL

  99. org.pentaho.di.core.database.PostgreSQLDatabaseMeta

  100.  
  101. Redshift

  102. org.pentaho.di.core.database.RedshiftDatabaseMeta

  103.  
  104. Remedy Action Request System

  105. org.pentaho.di.core.database.RemedyActionRequestSystemDatabaseMeta

  106.  
  107. MaxDB (SAP DB)

  108. org.pentaho.di.core.database.SAPDBDatabaseMeta

  109.  
  110. SQLite

  111. org.pentaho.di.core.database.SQLiteDatabaseMeta

  112.  
  113. Sybase

  114. org.pentaho.di.core.database.SybaseDatabaseMeta

  115.  
  116. SybaseIQ

  117. org.pentaho.di.core.database.SybaseIQDatabaseMeta

  118.  
  119. Teradata

  120. org.pentaho.di.core.database.TeradataDatabaseMeta

  121.  
  122. UniVerse database

  123. org.pentaho.di.core.database.UniVerseDatabaseMeta

  124.  
  125. Vertica

  126. org.pentaho.di.core.database.VerticaDatabaseMeta

  127.  
  128. Vertica 5+

  129. org.pentaho.di.core.database.Vertica5DatabaseMeta

  130.  

4.报错解决:

hive的api的连接方式是通过jdbc连接的。具体思路与postgresql的连接思路相同。因此仿照postgresql的连接方法自定义一个database-type为hive2。因此,在kettle-core-7.1.0.0-12.jar的kettle-database-types.xml文件中添加

 
  1. HIVE2

  2. org.pentaho.di.core.database.Hive2SQLDatabaseMeta

其中会有对应的实现类org.pentaho.di.core.database.Hive2SQLDatabaseMeta。

仿照postgresql的实现类org.pentaho.di.core.database.PostgreSQLDatabaseMeta来写即可,只需将连接的url以及jdbc driver名称更换为hive相关。

将org.pentaho.di.core.database.Hive2SQLDatabaseMeta类编译为.class文件放进kettle-core-7.1.0.0-12.jar的org\pentaho\di\core\database路径下

kettle-java代码执行hive相关ktr时报错: database type with plugin id [HIVE2] couldn't be found!_第1张图片

6.再次执行ktr:

执行成功:结果:

 
  1. {/hivetorizhi (master)=1cc5f5bb-b0c4-4938-96f7-85363f88564d, /hivetorizhi (local:slave1-8081)=09ea3633-f5bd-4e43-9352-62b958255469, /hivetorizhi (local:slave2-8082)=35e00dc2-f570-4f26-8540-156fb84d9524}

  2. /hivetorizhi (master)

  3. /hivetorizhi (local:slave2-8082)

  4.  

你可能感兴趣的:(kettle)