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

huangapple go评论124阅读模式
英文:

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

问题

  1. 我正在尝试运行一个连接到 HBase 的旧项目。
  2. 它有以下依赖之一:
  3. <dependency>
  4. <groupId>org.apache.hbase</groupId>
  5. <artifactId>hbase-client</artifactId>
  6. <version>1.2.0-cdh5.7.2</version>
  7. </dependency>
  8. 当应用程序启动并在 `org.apache.hadoop.hbase.client.ConnectionFactory` 类的 `createConnection` 方法内部到达以下代码时:
  9. try{
  10. ....
  11. return (Connection) constructor.newInstance(conf, managed, pool, user);
  12. } catch (Exception e) {
  13. throw new IOException(e);
  14. }
  15. 抛出并捕获了一个异常,错误信息为:
  16. java.lang.NoClassDefFoundError: org/apache/hadoop/crypto/key/KeyProviderTokenIssuer
  17. 因此,我在 Google 上寻找了 `KeyProviderTokenIssuer` 这个类,但没有找到它应该来自哪里。
  18. 为什么系统在尝试使用这个类,我应该从哪里获取它?`Crypto` 包不是 `hbase-client` 依赖的一部分,我在 [https://mvnrepository.com/][1] 上也没有找到这样的内容。
  19. 这里是否可能存在某种库不匹配?
  20. 我在 Windows 上运行。这可能有关吗?
  21. [1]: https://mvnrepository.com/
英文:

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

It has (among other dependencies):

  1. <dependency>
  2. <groupId>org.apache.hbase</groupId>
  3. <artifactId>hbase-client</artifactId>
  4. <version>1.2.0-cdh5.7.2</version>
  5. </dependency>

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

  1. try{
  2. ....
  3. return (Connection) constructor.newInstance(conf, managed, pool, user);
  4. } catch (Exception e) {
  5. throw new IOException(e);
  6. }

An exception is thrown and caught, saying that:

  1. 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?

答案1

得分: 2

我经过几个步骤成功解决了这个问题:

  • 在按照这篇帖子的指示后,我下载了hadoop-common-2.2.0-bin-master.zip文件,并将其完整解压到了C:\Program Files\apache\hadoop\bin文件夹中。

  • 我将HADOOP_HOME参数添加到系统变量中,指向C:\Program Files\apache\hadoop

  • 我将%HADOOP_HOME%\bin的值添加到了PATH变量中。

  • 由于我的Hadoop版本是2.6.0,我检查并确保所有与Hadoop相关的依赖项都是这个版本的。

  • 我运行了mvn dependency:tree命令,并发现其中一个依赖项的jar包携带了org.apache.hadoop:hadoop-hdfs-client:jar:3.2.0的jar包,所以我在依赖项中排除了它:

  1. <dependency>
  2. <groupId>com.example</groupId>
  3. <artifactId>bla</artifactId>
  4. <version>1.0.1</version>
  5. <exclusions>
  6. <exclusion>
  7. <groupId>org.apache.hadoop</groupId>
  8. <artifactId>hadoop-hdfs-client</artifactId>
  9. </exclusion>
  10. </exclusions>
  11. </dependency>

一些帮助我的网址:

英文:

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:

    1. &lt;dependency&gt;
    2. &lt;groupId&gt;com.example&lt;/groupId&gt;
    3. &lt;artifactId&gt;bla&lt;/artifactId&gt;
    4. &lt;version&gt;1.0.1&lt;/version&gt;
    5. &lt;exclusions&gt;
    6. &lt;exclusion&gt;
    7. &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
    8. &lt;artifactId&gt;hadoop-hdfs-client&lt;/artifactId&gt;
    9. &lt;/exclusion&gt;
    10. &lt;/exclusions&gt;
    11. &lt;/dependency&gt;

Some URLs that helped me:

huangapple
  • 本文由 发表于 2020年4月5日 21:57:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/61043740.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定