0

I have a HIVE/hadoop cluster and I can connect to and retrive data from tables using beeline while on a node beeline -u "jdbc:hive2://xxxxx02:10000/default;principal=hive/_HOST@DEV.HADOOP.XXXX.COM" , after generating the Kerberos ticket using kinit.

Any help is greatly appreciated !

I am unable to connect the same cluster when I have tried to use apache JDBC in a java class

  1. Eclipse is my IDE on a windows machine.
  2. I am using Hive JDBC driver
<dependency>
<groupId>org.apache.hive</groupId>
 <artifactId>hive-jdbc</artifactId>
<version>3.1.2</version>
</dependency>
  1. Hive version on cluster:
    $ rpm -qa|grep hadoop                             
        hadoop_2_6_0_3_8-yarn-2.7.3.2.6.0.3-8
        hadoop_2_6_0_3_8-libhdfs-2.7.3.2.6.0.3-8
        teradata-connector-1.4.3-hadoop2.x
        ambari-metrics-hadoop-sink-2.5.0.3-7
        hadoop_2_6_0_3_8-mapreduce-2.7.3.2.6.0.3-8
        teradata-hadoop-tools-2.16.12.48-1
        teradata-hadoop-builder-2.6.25.22-1
        hadoop_2_6_0_3_8-2.7.3.2.6.0.3-8
        hadoop_2_6_0_3_8-client-2.7.3.2.6.0.3-8
        hadoop_2_6_0_3_8-hdfs-2.7.3.2.6.0.3-8
  1. I have generated a keytab file from the node and copied on windows machine where I am running Java class

  2. here is the code `


    try {
                Class.forName("org.apache.hive.jdbc.HiveDriver");
                System.setProperty("sun.security.jgss.debug", "true");
                System.setProperty("java.security.auth.login.config", "jaas1.conf");
                System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
                System.setProperty("java.security.krb5.conf", "krb5.ini");
                System.out.println("Connecting...");
                Connection con = DriverManager.getConnection(
                        "jdbc:hive2://xxx02.xxx.com:10000/default;principal=hive/xxx02.xxx.com@DEV.HADOOP.XXXX.COM;");
                System.out.println("...Connected");
                con.close();

            } catch (ClassNotFoundException e) {
                logger.error("Driver not found");
            } catch (Exception e) {
                e.printStackTrace();
            }

  1. jaas1.conf and krb5.ini is in Eclipse root project folder.

jaas1.conf is below:

>     Client {
>      com.sun.security.auth.module.Krb5LoginModule required
>     useKeyTab=true
>     keyTab=”c:\users\shiredd\spr.keytab”
>     principal="shiredd@ABC.COM"
>     doNotPrompt=true;
>     };
  1. error is:
    connecting...

    Search Subject for Kerberos V5 INIT cred (<<DEF>>, sun.security.jgss.krb5.Krb5InitCredential)
    15686 [WARN] HiveConnection: Failed to connect to xxx02.abc.com:10000

    java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://xxx02.abc.com:10000/default;principal=hive/xxxx02.abc.com@DEV.HADOOP.ABC.COM;: java.io.IOException: Configuration Error:
        Line 4: expected [option key], found [null]
        at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:256)
        at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at ca.loblaw.eiBuildingBlocks.HiveJDBCOverHTTP.main(HiveJDBCOverHTTP.java:36)
    Caused by: java.lang.SecurityException: java.io.IOException: Configuration Error:
        Line 4: expected [option key], found [null]
        at sun.security.provider.ConfigFile$Spi.<init>(Unknown Source)
        at sun.security.provider.ConfigFile.<init>(Unknown Source)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        at javax.security.auth.login.Configuration$2.run(Unknown Source)
        at javax.security.auth.login.Configuration$2.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.login.Configuration.getConfiguration(Unknown Source)
        at sun.security.jgss.LoginConfigImpl$1.run(Unknown Source)
        at sun.security.jgss.LoginConfigImpl$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.security.jgss.LoginConfigImpl.<init>(Unknown Source)
        at sun.security.jgss.GSSUtil.login(Unknown Source)
        at sun.security.jgss.krb5.Krb5Util.getInitialTicket(Unknown Source)
        at sun.security.jgss.krb5.Krb5InitCredential$1.run(Unknown Source)
        at sun.security.jgss.krb5.Krb5InitCredential$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.security.jgss.krb5.Krb5InitCredential.getTgt(Unknown Source)
        at sun.security.jgss.krb5.Krb5InitCredential.getInstance(Unknown Source)
        at sun.security.jgss.krb5.Krb5MechFactory.getCredentialElement(Unknown Source)
        at sun.security.jgss.krb5.Krb5MechFactory.getMechanismContext(Unknown Source)
        at sun.security.jgss.GSSManagerImpl.getMechanismContext(Unknown Source)
        at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
        at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
        at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(Unknown Source)
        at org.apache.thrift.transport.TSaslClientTransport.handleSaslStartMessage(TSaslClientTransport.java:94)
        at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:271)
        at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37)
        at org.apache.hadoop.hive.metastore.security.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:51)
        at org.apache.hadoop.hive.metastore.security.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:48)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Unknown Source)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)
        at org.apache.hadoop.hive.metastore.security.TUGIAssumingTransport.open(TUGIAssumingTransport.java:48)
        at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:343)
        at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:228)
        ... 4 more
    Caused by: java.io.IOException: Configuration Error:
        Line 4: expected [option key], found [null]
        at sun.security.provider.ConfigFile$Spi.ioException(Unknown Source)
        at sun.security.provider.ConfigFile$Spi.match(Unknown Source)
        at sun.security.provider.ConfigFile$Spi.parseLoginEntry(Unknown Source)
        at sun.security.provider.ConfigFile$Spi.readConfig(Unknown Source)
        at sun.security.provider.ConfigFile$Spi.init(Unknown Source)
        at sun.security.provider.ConfigFile$Spi.init(Unknown Source)
        ... 43 more**

0 Answers0