Cannot connect to HBase using Java

前端 未结 4 1112
长发绾君心
长发绾君心 2021-01-26 06:08

I am trying to use Java to connect HBase. There are only 1 node, which is my own machine. It seems that I cannot connect successfully.

Here is my Java code:

<         


        
相关标签:
4条回答
  • 2021-01-26 06:18

    Provide the full path to this jar like this ->

    sc.addJar("htrace-core.jar");
    
    0 讨论(0)
  • 2021-01-26 06:23

    Caused by:

    java.lang.NoClassDefFoundError: org/cloudera/htrace/Trace
    

    Based on this line in error stack trace including htrace-core.jar might help.

    0 讨论(0)
  • 2021-01-26 06:25

    I got this error when connecting to Hbase from java library without spark as well. I have added below classpath but it didn't work

    export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hbase/*
    

    But then i added hbase-solr path as htrace jar is present inside this path

    export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hbase/*:/usr/lib/hbase-solr/lib/*
    

    Hope this should work for you.

    0 讨论(0)
  • 2021-01-26 06:41

    For Spark-HBase integration, the best way is to add HBase libraries to Spark Classpath. This can be done using the 'compute-classpath.sh' script in $SPARK_HOME/bin folder. Spark invokes 'compute-classpath.sh' and picks up the required hbase jars hence.

    export CLASSPATH=$CLASSPATH:<path/to/HBase/lib/*>
    

    eg: export CLASSPATH=$CLASSPATH:/opt/cloudera/parcels/CDH/lib/hbase/lib/*

    After this, restart Spark.

    There you go :)

    0 讨论(0)
提交回复
热议问题