javahadoopjakarta-eehdfskerberos

Error: `callbackHandler` may not be null when connecting to HDFS using Kerberos in Jakarta EE


I am trying to connect to HDFS using Kerberos authentication in a JakartaEE application. The connection code appears to be set up correctly, but I am encountering the following error when attempting to load a file list from HDFS:

14:41:17,006 ERROR [com.hdfs.HdfsFileBrowserBean] (default task-1) Failed to load file list for path: /: java.io.IOException: DestHost:destPort java.ecc.com:8020, LocalHost:localPort localhost.localdomain/127.0.0.1:0. Failed on local exception: java.io.IOException: Couldn't set up IO streams: java.lang.IllegalArgumentException: Parameter 'callbackHandler' may not be null

This suggests that there is an issue with the callbackHandler. I have verified the keytab and principal details but am unsure how to resolve this specific error.

Configuration conf = new Configuration();
setClusterConfig(conf, peerCrawler.getClusterConfig(url, username, password, "hdfs-site"));
setClusterConfig(conf, peerCrawler.getClusterConfig(url, username, password, "core-site"));

String keytabPath = "/opt/wildfly-34.0.0.Final/keytabs/yarn.service.keytab"; 
String principal = "yarn/java.ecc.com@ECC.COM"; 
org.apache.hadoop.conf.Configuration hadoopConfig = new org.apache.hadoop.conf.Configuration();
hadoopConfig.set("hadoop.security.authentication", "kerberos");
UserGroupInformation.setConfiguration(hadoopConfig);
UserGroupInformation.loginUserFromKeytab(principal, keytabPath);

String currentUser = UserGroupInformation.getCurrentUser().getUserName();
logger.info("Login successful with principal: " + currentUser);

// Get FileSystem instance
this.fileSystem = FileSystem.get(new URI(hdfsUri), conf);

Could anyone help me understand why I'm receiving this error and how to resolve it? Any insights on the callbackHandler parameter would be greatly appreciated.


Solution

  • damm, the problem lies in the CDI, and another part of the code has interrupted the connection with the IPC client.