Reputation: 69
I have a java program that uses a kerberos keytab file to securely log in to my hadoop server. I have used the below code to configure everything and it works perfectly fine in Eclipse IDE, but when I create an executable jar out of it, via Maven, and run on command line, it doesn't work. I see that it is able to read the keytab file but not able to retreive the password for the user id specified, thus the error. Any advise?
Configuration conf = new Configuration();
conf.set("hadoop.security.authentication", "kerberos");
UserGroupInformation.setConfiguration(conf);
URL file = this.getClass().getClassLoader().getResource("file.keytab");
UserGroupInformation.loginUserFromKeytab("xyzUser", file.getPath());
My keytab file is saved in the root folder and I have added it to my pom.xml as a resource tag. Below is the command I am testing my jar file with:
java -jar myjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar
Upvotes: 1
Views: 11222
Reputation: 849
make sure the keytab file is in the current directory, other than classpath.
Upvotes: 0