通过R类错误连接到HIve JDBC

时间:2017-05-02 15:07:14

标签: r jdbc hive

我正在尝试使用R JDBC库连接到hive。我的代码如下所示:

library('DBI')
library('rJava')
library('RJDBC')

hadoop.class.path = list.files(path=c('/usr/hdp/hadoop/'), pattern='jar', full.names=T);
hadoop.lib.path = list.files(path=c('/usr/hdp/hadoop/lib/'), pattern='jar', full.names=T);
hive.class.path = list.files(path=c('/usr/hdp/hive/lib/'), pattern='jar', full.names=T);
mapred.class.path = list.files(path=c('/usr/hdp/hadoop-mapreduce'), pattern='jar', full.names=T);
cp = c(hadoop.class.path, hadoop.lib.path, hive.class.path, mapred.class.path, '/usr/hdp/hadoop-mapreduce/hadoop-mapreduce-client-core.jar')
.jinit(classpath=cp)

drv <- JDBC('org.apache.hive.jdbc.HiveDriver', '/usr/hdp/hive/lib/hive-jdbc.jar')
con <- dbConnect(drv, 'jdbc:hive2://my.cluster.net:10000/default;principal=hive/my.cluster.net@domain.com', 'hive', 'hive')

但是当我跑步时,我收到以下错误:

java.lang.NoClassDefFoundError: Could not initialize class org.apache.hadoop.security.SecurityUtil

但是,我检查了我的/usr/hdp/hadoop/hadoop-commons.jar,发现org.apache.hadoop.security.SecurityUtil类就在那里。那还有什么可能导致这个错误?

0 个答案:

没有答案