Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Failing to connect kerberos hive from local eclipse

Highlighted

Failing to connect kerberos hive from local eclipse

New Contributor

Here is the code

package hive.connect.java.hive.connect.java;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
public class App {
private static Connection hiveConnection;
// get Hive Connection
public static void  main(String [] args) throws IOException, SQLException {
    System.out.println("Preparing Hive connection1");
    Configuration conf = new Configuration();
   // System.setProperty("javax.security.auth.useSubjectCredsOnly","false");
    conf.set("hadoop.security.authentication", "Kerberos");
    UserGroupInformation.setConfiguration(conf);
   UserGroupInformation.loginUserFromKeytab("user", "keytab");
    
    // Hive Connection
    try {
        Class.forName("org.apache.hive.jdbc.HiveDriver");
        if(hiveConnection == null) {
            hiveConnection = DriverManager.getConnection("jdbc:hive2://host:10000/;principal=user;auth=kerberos;kerberosAuthType=fromSubject");
                       // return hiveConnection;
        } else {
        //return hiveConnection;
        }
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
       // return null;
    } catch (SQLException e) {
        e.printStackTrace();
        // return null;
    }
}
}



the error I am getting -

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.security.authentication.util.KerberosUtil.hasKerberosKeyTab(Ljavax/security/auth/Subject;)Z

What am I missing here