Search code examples
javareflectionhbasehbase-client

HBase client - java.lang.ClassNotFoundException: org.apache.hadoop.crypto.key.KeyProviderTokenIssuer


I'm trying to run a legacy project that connects to HBase.

It has (among other dependencies):

    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-client</artifactId>
        <version>1.2.0-cdh5.7.2</version>
    </dependency>

When the application starts and reaches this code within the method of createConnection in the class of org.apache.hadoop.hbase.client.ConnectionFactory:

try{
    .... 
    return (Connection) constructor.newInstance(conf, managed, pool, user);
} catch (Exception e) {
  throw new IOException(e);
}

An exception is thrown and caught, saying that:

java.lang.NoClassDefFoundError: org/apache/hadoop/crypto/key/KeyProviderTokenIssuer

So I was looking for this class of KeyProviderTokenIssuer in Google but didn't find where it should come from.

Why the system is trying to use this class and where should I get it from? Crypto package is not part of the hbase-client dependency and I don't see such in https://mvnrepository.com/

Is it possible that there is some library mismatch here?

I'm running on Windows. Can it be related?


Solution

  • I was able to overcome this issue after performing several steps:

    • Following this post , I downloaded the file of hadoop-common-2.2.0-bin-master.zip and fully extracted it to the folder of C:\Program Files\apache\hadoop\bin

    • I added the HADOOP_HOME param to the system variables, pointing it to C:\Program Files\apache\hadoop

    • I added to the PATH variable the value of %HADOOP_HOME%\bin

    • Since my Hadoop is version 2.6.0 I checked and made sure that all Hadoop related dependencies are in that version.

    • I run mvn dependency:tree and found that one of the dependencies jars is bringing with it the jar of org.apache.hadoop:hadoop-hdfs-client:jar:3.2.0 so I excluded it from the dependency:

      <dependency>
          <groupId>com.example</groupId>
          <artifactId>bla</artifactId>
          <version>1.0.1</version>
          <exclusions>
              <exclusion>
                  <groupId>org.apache.hadoop</groupId>
                  <artifactId>hadoop-hdfs-client</artifactId>
              </exclusion>
          </exclusions>
      </dependency>
      

    Some URLs that helped me: