在整合flume + kafka + storm + hbase 时,出现

java.lang.ClassNotFoundException: org.apache.hadoop.hbase.HBaseConfiguration

起初从网上搜到俩个解决方法

1、在hadoop-env.sh 加了下面那句

2、在hadoop的lib下加了hbase-common-1.3.1.jar

但还是报错

后来又把这几个jar拷贝到storm/lib 下,又出现一下错误

Exception in thread "main" java.io.IOException: java.lang.reflect.InvocationTargetException
        at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:240)
        at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:218)
        at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:119)
        at demo.myconnection.main(myconnection.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:238)
        ... 9 more
Caused by: java.lang.NoClassDefFoundError: org/apache/htrace/Trace
        at org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper.exists(RecoverableZooKeeper.java:217)
        at org.apache.hadoop.hbase.zookeeper.ZKUtil.checkExists(ZKUtil.java:419)
        at org.apache.hadoop.hbase.zookeeper.ZKClusterId.readClusterIdZNode(ZKClusterId.java:65)
        at org.apache.hadoop.hbase.client.ZooKeeperRegistry.getClusterId(ZooKeeperRegistry.java:105)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.retrieveClusterId(ConnectionManager.java:919)
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.<init>(ConnectionManager.java:657)
        ... 14 more
Caused by: java.lang.ClassNotFoundException: org.apache.htrace.Trace
 

从根源来说,以上故障都是因为执行时找不到对应的hbase jar包引起的。

那么解决思路有两条:

1. 手动copy缺失的jar包

           拷贝 hbase/lib 下 hbase*.jar,metrics*.jar.htrace*.jar  复制到 storm/lib/ 下


2. 设置classpath环境变量

执行

export HBASE_CLASSPATH=`hbase classpath`

export HADOOP_CLASSPATH=`hadoop classpath`

exportHADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HBASE_CLASSPATH

原文链接:https://blog.csdn.net/ray_mnd2010/article/details/54407440

Logo

Kafka开源项目指南提供详尽教程,助开发者掌握其架构、配置和使用,实现高效数据流管理和实时处理。它高性能、可扩展,适合日志收集和实时数据处理,通过持久化保障数据安全,是企业大数据生态系统的核心。

更多推荐