0

I'm trying to connect R to Hadoop using Phoenix but I get the following error:

Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], : java.sql.SQLException: java.lang.IllegalArgumentException: Can't get Kerberos realm

Below you can find my R code. Anyone knows how to correct this to be able to connect without errors?

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

Sys.setenv(JAVA_TOOL_OPTIONS="-Djava.security.krb5.conf=/path/to/krb5.conf")

.jinit(,"-Djavax.security.auth.useSubjectCredsOnly=false")

.jaddClassPath(Sys.glob("/path/to/site-xml"))
# this folder contains core-site.xml, hbase-site.xml and hdfs-site.xml

drv <- JDBC("org.apache.phoenix.jdbc.PhoenixDriver", 
     "/path/to/phoenix-4.4.0.2.3.2.0-2950-client.jar",
     identifier.quote = "'"
     )

conn <- dbConnect(
  drv,
  "jdbc:phoenix:IP1,IP2,IP3:2181:/hbase-secure:USER@HADOOP.COM:/path/to/keytab/file.keytab",
  "",
  ""
)

result <- dbGetQuery(conn, "select * from \"TABLE_NAME\"")
print(result)
pheeleeppoo
  • 1,491
  • 6
  • 25
  • 29
  • The "Kerberos realm" should be defined in your `krb5.conf` file. Why do you pass 2 different Java properties in 2 different ways? Are you confident that JAVA_TOOL_OPTIONS env var is actually used by Java? – Samson Scharfrichter Aug 27 '18 at 18:20
  • On second thoughts JAVA_TOOL_OPTIONS looks good, or I'm a fool https://stackoverflow.com/questions/43778821/issue-connecting-rstudio-but-not-r-to-hive-with-kerberos > but add some debug flags there `-Dsun.security.krb5.debug=true -Djava.security.debug=gssloginconfig,configfile,configparser,logincontext` – Samson Scharfrichter Aug 27 '18 at 18:26
  • @SamsonScharfrichter, thank you for your answer. The Kerberos realm is already defined in krb5.conf file. About the debug flags, I added them as you said but it did not help... – Mário Lopes Aug 28 '18 at 08:17

0 Answers0