I am trying to open jdbc connection from java app when running on windows pc.
Hive is already installed on a oracle linux server. I am using kerberos for secure authentication. I took ticket using the keytab when keytab run on linux server. It works perfectly. I get keytab file in windows pc to use for creating ticket before create connection.
my java code is
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.hadoop.security.UserGroupInformation;
public class Ana { private static String driverName = "org.apache.hive.jdbc.HiveDriver"; public static void main(String[] args) throws SQLException, IOException { try { org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); conf.set("hadoop.security.authentication", "Kerberos"); conf.set("hive.server2.authentication", "Kerberos"); UserGroupInformation.setConfiguration(conf); UserGroupInformation.loginUserFromKeytab( "[email protected]", "C:\\Users\\neverwinter\\Documents\\calisan\\yeni2\\neverwinter.keytab"); Class.forName(driverName); } catch ( ClassNotFoundException e ) { e.printStackTrace(); System.exit(1); } Connection con = DriverManager .getConnection("jdbc:hive2://myHost:10000/TGAR;principal=hive/[email protected]"); Statement stmt = con.createStatement(); String tableName = "newTable"; stmt.execute("drop table if exists " + tableName); stmt.execute("create table " + tableName + " (key int, value string)"); }
}my pom xml is
<dependency> <groupId>org.apache.hive</groupId> <artifactId>hive-jdbc</artifactId> <version>1.2.1</version> <exclusions> <exclusion> <groupId>jdk.tools</groupId> <artifactId>jdk.tools</artifactId> </exclusion> </exclusions>
</dependency>
<dependency> <groupId>org.apache.hive</groupId> <artifactId>hive-exec</artifactId> <version>0.13.0</version>
</dependency>
<dependency> <groupId>org.apache.hive</groupId> <artifactId>hive-jdbc</artifactId> <version>0.13.0</version>
</dependency>
<dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> <version>0.9.0</version>
</dependency>
<dependency> <groupId>org.apache.thrift</groupId> <artifactId>libfb303</artifactId> <version>0.9.0</version>
</dependency>
<dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.3</version>
</dependency>
<dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> <version>2.6.0</version>
</dependency>When the line getConnection it throws the error below:
Caused by: org.apache.thrift.transport.TTransportException: GSS initiate failed at org.apache.thrift.transport.TSaslTransport.sendAndThrowMessage(TSaslTransport.java:221) at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:297) at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37) at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:52) at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport$1.run(TUGIAssumingTransport.java:49) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Unknown Source) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628) at org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport.open(TUGIAssumingTransport.java:49) at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:203) ... 5 more
JVM parameters
-Djava.security.krb5.debug=true
-Djava.security.krb5.conf="C:\Users\neverwinter\Desktop\krb5.conf"
-Djava.security.auth.login.config="C:\Users\neverwinter\Desktop\gss-jaas.conf"I searched about gss fails but nothing can help about that case. What is the thing that I am missing? Any idea would be great.
4 Related questions 3 javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided 1 Java - Failed to specify server's Kerberos principal name 1 How to access hive database from secured kerberos environment using java Related questions 3 javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided 1 Java - Failed to specify server's Kerberos principal name 1 How to access hive database from secured kerberos environment using java 2 Hive JDBC connection issues with Kerberos authentication - R 2 Cannot connect to HIVE with Secured kerberos. I am using UserGroupInformation.loginUserFromKeytab() 2 Connect to kerberised hive using jdbc from remote windows system 1 Hive JDBC Kerberose Authentication Error: GSS initiate failed 1 Hive JDBC Kerberos Connectivity error 0 Exception while connecting to Hive using JDBC and Kerberos authentication 0 connection time out to hiveserver2 using keytab from java Load 7 more related questions Show fewer related questions Reset to default