今天编译安装了kettle8.3.10-R版本,然后连上公司的hadoop环境,测试hive2连接时报错:

错误连接数据库 [hive_hdp] : org.pentaho.di.core.exception.KettleDatabaseException: 
Error occurred while trying to connect to the database

Error connecting to database: (using class org.apache.hive.jdbc.HiveDriver)
org/apache/hive/service/cli/thrift/TCLIService$Iface


org.pentaho.di.core.exception.KettleDatabaseException: 
Error occurred while trying to connect to the database

Error connecting to database: (using class org.apache.hive.jdbc.HiveDriver)
org/apache/hive/service/cli/thrift/TCLIService$Iface


	at org.pentaho.di.core.database.Database.normalConnect(Database.java:477)
	at org.pentaho.di.core.database.Database.connect(Database.java:373)
	at org.pentaho.di.core.database.Database.connect(Database.java:344)
	at org.pentaho.di.core.database.Database.connect(Database.java:334)
	at org.pentaho.di.core.database.DatabaseFactory.getConnectionTestReport(DatabaseFactory.java:83)
	at org.pentaho.di.core.database.DatabaseFactory.getConnectionTestResults(DatabaseFactory.java:112)
	at org.pentaho.di.core.database.DatabaseMeta.testConnectionSuccess(DatabaseMeta.java:2843)
	at org.pentaho.ui.database.event.DataHandler.testDatabaseConnection(DataHandler.java:631)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.pentaho.ui.xul.impl.AbstractXulDomContainer.invoke(AbstractXulDomContainer.java:313)
	at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:157)
	at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:141)
	at org.pentaho.ui.xul.swt.tags.SwtButton.access$500(SwtButton.java:43)
	at org.pentaho.ui.xul.swt.tags.SwtButton$4.widgetSelected(SwtButton.java:137)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
	at org.eclipse.jface.window.Window.open(Window.java:796)
	at org.pentaho.di.ui.xul.KettleDialog.show(KettleDialog.java:89)
	at org.pentaho.di.ui.xul.KettleDialog.show(KettleDialog.java:56)
	at org.pentaho.di.ui.core.database.dialog.XulDatabaseDialog.open(XulDatabaseDialog.java:117)
	at org.pentaho.di.ui.core.database.dialog.DatabaseDialog.open(DatabaseDialog.java:61)
	at org.pentaho.di.ui.trans.step.BaseStepDialog.showDbDialogUnlessCancelledOrValid(BaseStepDialog.java:813)
	at org.pentaho.di.ui.trans.step.BaseStepDialog$EditConnectionListener.widgetSelected(BaseStepDialog.java:1521)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
	at org.pentaho.big.data.kettle.plugins.hive.trans.HiveOutputDialog.open(HiveOutputDialog.java:686)
	at org.pentaho.di.ui.spoon.delegates.SpoonStepsDelegate.editStep(SpoonStepsDelegate.java:120)
	at org.pentaho.di.ui.spoon.Spoon.editStep(Spoon.java:8814)
	at org.pentaho.di.ui.spoon.trans.TransGraph.editStep(TransGraph.java:3287)
	at org.pentaho.di.ui.spoon.trans.TransGraph.mouseDoubleClick(TransGraph.java:785)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
	at org.pentaho.di.ui.spoon.Spoon.readAndDispatch(Spoon.java:1384)
	at org.pentaho.di.ui.spoon.Spoon.waitForDispose(Spoon.java:7949)
	at org.pentaho.di.ui.spoon.Spoon.start(Spoon.java:9331)
	at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:710)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.pentaho.commons.launcher.Launcher.main(Launcher.java:92)
Caused by: org.pentaho.di.core.exception.KettleDatabaseException: 
Error connecting to database: (using class org.apache.hive.jdbc.HiveDriver)
org/apache/hive/service/cli/thrift/TCLIService$Iface

	at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:590)
	at org.pentaho.di.core.database.Database.normalConnect(Database.java:461)
	... 56 more
Caused by: java.lang.NoClassDefFoundError: org/apache/hive/service/cli/thrift/TCLIService$Iface
	at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:208)
	at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:572)
	... 57 more
Caused by: java.lang.ClassNotFoundException: org.apache.hive.service.cli.thrift.TCLIService$Iface
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 61 more

在jvm参数中加上-verbose:class,发现org.apache.hive.service.cli.thrift.TCLIService$Iface类是加载了的。

[Loaded org.apache.hive.jdbc.HiveDriver from file:///D:/etl/8.3/data-integration/plugins/pentaho-big-data-plugin/hadoop-configurations/hdp30/lib/hive-jdbc-3.1.0.3.0.0.0-1634.jar]

于是debug模式启动kettle,发现日志中额外打印如下错误:

11:01:54,401 ERROR [HiveConnection] Error opening session
org.apache.thrift.TApplicationException: Required field 'client_protocol' is unset! Struct:TOpenSessionReq(client_protocol:null, configuration:{set:hiveconf:hive.server2.thrift.resultset.default.fetch.size=1000, use:database=default})
	at org.apache.thrift.TApplicationException.read(TApplicationException.java:111)
	at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:79)
	at org.apache.hive.service.rpc.thrift.TCLIService$Client.recv_OpenSession(TCLIService.java:176)
	at org.apache.hive.service.rpc.thrift.TCLIService$Client.OpenSession(TCLIService.java:163)
	at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:715)
	at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:228)
	at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
	at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.pentaho.hadoop.shim.common.invocationhandler.DriverInvocationHandler.invoke(DriverInvocationHandler.java:73)
	at com.sun.proxy.$Proxy74.connect(Unknown Source)
	at com.pentaho.big.data.bundles.impl.shim.hive.HiveDriver.doConnect(HiveDriver.java:97)
	at com.pentaho.big.data.bundles.impl.shim.hive.HiveDriver.connect(HiveDriver.java:78)
	at org.pentaho.big.data.api.jdbc.impl.LazyDelegatingDriver.lambda$connect$0(LazyDelegatingDriver.java:114)
	at org.pentaho.big.data.api.jdbc.impl.LazyDelegatingDriver.findAndProcess(LazyDelegatingDriver.java:72)
	at org.pentaho.big.data.api.jdbc.impl.LazyDelegatingDriver.connect(LazyDelegatingDriver.java:114)
	at org.pentaho.di.core.database.DelegatingDriver.connect(DelegatingDriver.java:53)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:208)
	at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:572)
	at org.pentaho.di.core.database.Database.normalConnect(Database.java:461)
	at org.pentaho.di.core.database.Database.connect(Database.java:373)
	at org.pentaho.di.core.database.Database.connect(Database.java:344)
	at org.pentaho.di.core.database.Database.connect(Database.java:334)
	at org.pentaho.di.core.database.DatabaseFactory.getConnectionTestReport(DatabaseFactory.java:83)
	at org.pentaho.di.core.database.DatabaseFactory.getConnectionTestResults(DatabaseFactory.java:112)
	at org.pentaho.di.core.database.DatabaseMeta.testConnectionSuccess(DatabaseMeta.java:2843)
	at org.pentaho.ui.database.event.DataHandler.testDatabaseConnection(DataHandler.java:631)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.pentaho.ui.xul.impl.AbstractXulDomContainer.invoke(AbstractXulDomContainer.java:313)
	at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:157)
	at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:141)
	at org.pentaho.ui.xul.swt.tags.SwtButton.access$500(SwtButton.java:43)
	at org.pentaho.ui.xul.swt.tags.SwtButton$4.widgetSelected(SwtButton.java:137)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
	at org.eclipse.jface.window.Window.open(Window.java:796)
	at org.pentaho.di.ui.xul.KettleDialog.show(KettleDialog.java:89)
	at org.pentaho.di.ui.xul.KettleDialog.show(KettleDialog.java:56)
	at org.pentaho.di.ui.core.database.dialog.XulDatabaseDialog.open(XulDatabaseDialog.java:117)
	at org.pentaho.di.ui.core.database.dialog.DatabaseDialog.open(DatabaseDialog.java:61)
	at org.pentaho.di.ui.trans.step.BaseStepDialog.showDbDialogUnlessCancelledOrValid(BaseStepDialog.java:813)
	at org.pentaho.di.ui.trans.step.BaseStepDialog$EditConnectionListener.widgetSelected(BaseStepDialog.java:1521)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
	at org.pentaho.big.data.kettle.plugins.hive.trans.HiveOutputDialog.open(HiveOutputDialog.java:686)
	at org.pentaho.di.ui.spoon.delegates.SpoonStepsDelegate.editStep(SpoonStepsDelegate.java:120)
	at org.pentaho.di.ui.spoon.Spoon.editStep(Spoon.java:8814)
	at org.pentaho.di.ui.spoon.trans.TransGraph.editStep(TransGraph.java:3287)
	at org.pentaho.di.ui.spoon.trans.TransGraph.mouseDoubleClick(TransGraph.java:785)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
	at org.pentaho.di.ui.spoon.Spoon.readAndDispatch(Spoon.java:1384)
	at org.pentaho.di.ui.spoon.Spoon.waitForDispose(Spoon.java:7949)
	at org.pentaho.di.ui.spoon.Spoon.start(Spoon.java:9331)
	at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:710)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.pentaho.commons.launcher.Launcher.main(Launcher.java:92)

然后搜索Required field ‘client_protocol’ is unset!这个问题,在StackOverflow上找到这个问题:
https://stackoverflow.com/questions/24694415/required-field-client-protocol-is-unset
里面第一个回答就说了为什么会出现这个问题:
因为client和server的版本不匹配,client的jar包版本高于server的版本。
然后对比了版本,果然,client是3.1,server是2.6.

于是换了client的相关jar包后,连接正常。

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐