gpt4 book ai didi

java - 由 : java. lang.ClassNotFoundException : org. apache.zookeeper.KeeperException 引起

转载 作者:可可西里 更新时间:2023-11-01 14:54:27 31 4
gpt4 key购买 nike

当我在 Eclipse IDE 下运行 JAVA 程序(不能新建 HTable)时,出现以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/zookeeperKeeperException
at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:185)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:154)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:132)
at HBaseConnector.main(HBaseConnector.java:27)
Caused by: java.lang.ClassNotFoundException: org.apache.zookeeper.KeeperException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;

public class HBaseConnector {
public static void main(String[] args) throws IOException {
Configuration config = HBaseConfiguration.create();
HTable table = new HTable(config, "myLittleHBaseTable");
...
}

--------------
used jar files:
hbase-0.94.6-cdh4.3.0.jar
zookeeper-3.4.5-cdh4.3.0-tests.jar
lf4j-log4j12-1.7.5.jar
commons-configuration-1.9.jar
com.springsource.org.apache.commons.logging-1.1.1.jar
commons-lang-2.6.jar
hadoop-core-0.20.0.jar

哪里错了?

最佳答案

试试这个

我通过编辑文件“/usr/local/hbase-0.94.1/conf/hbase-env.sh”并添加元素“export HBASE_CLASSPATH=/usr/local/hbase-0.94.1/lib”来解决这个问题".

zookeeper JAR 位于“/usr/local/hbase-0.94.1/lib”的 HBase 安装中。

关于java - 由 : java. lang.ClassNotFoundException : org. apache.zookeeper.KeeperException 引起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19150604/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com