Problems using hbase-spark on CDH
- 5 replies
- 8708 views
- Translate All
Hello,
I am trying to use hbase-spark in order to query over Hbase with spark-sql, but I am stuck with some of these exceptions:
java.lang.NullPointerException
or
java.lang.NoSuchMethodError: org.apache.hadoop.hbase.util.ByteStringer.wrap([B)Lcom/google/protobuf/ByteString;
Contents :
1- Details on the platform
2- Details on the problem
3- Description of the attached content
1- A Cloudera cluster running CDH-6.3.4
2- I run a (POC) Java application with spark-submit in yarn cluster mode. What the application does is to sequencially :
- Create a Hbase table and populate it using the Java API
- Use a spark-session to read the hbase table (using .format("org.apache.hadoop.hbase.spark") )
- Perform some queries on the Dataframe.
For now, I only got partial success on the last step. I can show the contents of the dataframe with this for example :
Dataset<Row> sqlDF1 = sqlContext.sql("SELECT * FROM census2");
sqlDF1.show(100, false);
But the following code fails with one of the two exceptions listed at the start of the post :
Dataset<Row> sqlDF2 = sqlContext.sql("SELECT * FROM census2 WHERE ID1 LIKE '____|001_|%'");
sqlDF2.show(100, false);
Concerning this exception :
java.lang.NoSuchMethodError: org.apache.hadoop.hbase.util.ByteStringer.wrap([B)Lcom/google/protobuf/ByteString;
I see that the class is provided by the hbase-protocol project, as can be seen here : hbase/ByteStringer.java at rel/2.1.0 · apache/hbase · GitHub
I included the jar with the --jar option in the spark-submit, and it is also present in the uber-jar that is launched. So I don't see why I get this error.
I tried to use both hbase-spark 2.1.0-cdh6.3.4 maven-central dependency as well as a hbase-spark library that I compiled myself, but it did not help.
I also tried to add this to my sparksession :
// .config("spark.jars", "hbase-spark-1.0.0.jar:hbase-protocol-2.1.0.jar")
But then I get NullPointerException and cannot even print the dataframes.
I also tried to add :
.option("hbase.spark.use.hbasecontext", false)
when reading the dataframe (as I found someone suggesting that) but it did not help either.
3- Description of the attached content
- Main.java.txt => the code of the sample application
- launcher.sh.txt => the bash code used to launch the application
- jars_and_classpaths.txt => the jars passed to the --jars command, as well as the java client classpath
- mvn_dependency_tree.txt => the results of the command mvn dependency:tree
I am stuck here, could someone help me ?
Thanks a lot

