hadoop-hdfs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From IGZ Nick <igznic...@gmail.com>
Subject Accessing secure kerberized HDFS from Java code
Date Wed, 16 May 2012 18:59:18 GMT
I am trying to access some file in a secure HDFS cluster through java like
this:

private static Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);

However, this fails on the FileSystem.get() line with this exception:

May 16, 2012 11:33:31 AM org.apache.hadoop.security.UserGroupInformation
doAs
SEVERE: PriviledgedActionException as:griduser
cause:javax.security.sasl.SaslException: GSS initiate failed [Caused by
GSSException: No valid credentials provided (Mechanism level: Failed to
find any Kerberos tgt)]
May 16, 2012 11:33:31 AM org.apache.hadoop.ipc.Client$Connection$1 run
WARNING: Exception encountered while connecting to the server :
javax.security.sasl.SaslException: GSS initiate failed [Caused by
GSSException: No valid credentials provided (Mechanism level: Failed to
find any Kerberos tgt)]
May 16, 2012 11:33:31 AM org.apache.hadoop.security.UserGroupInformation
doAs
SEVERE: PriviledgedActionException as:griduser cause:java.io.IOException:
javax.security.sasl.SaslException: GSS initiate failed [Caused by
GSSException: No valid credentials provided (Mechanism level: Failed to
find any Kerberos tgt)]

I am running it like
java -cp <jars> <classname>

I am able to access the files using the normal command line as the same
user. e.g,
hadoop dfs -get <file> <dest> works perfectly.

I think this is because I have added this line to the hadoop executable:
kinit -k -t <keytab file> <username>

But how can I do this from the java code?

Thanks in advance for your help,

Mime
View raw message