我想处理spark上的数据并将其插入HBase。我在用 Hbase-Spark(Apache HBase)库(https://mvnrepository.com/artifact/org.apache.hbase/hbase-spark/2.0.0-alpha4)
我收到以下异常,
Caused by: java.lang.NoClassDefFoundError: org/apache/spark/Logging
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.hadoop.hbase.spark.JavaHBaseContext.<init>(JavaHBaseContext.scala:46)
at job.sqoop_process.HostLookupGenerator.insert(HostLookupGenerator.java:44)
at job.sqoop_process.SparkSqoopJob.process(SparkSqoopJob.java:17)
at job.spark.SparkExecutor$Executor.execute(SparkExecutor.java:75)
at job.spark.SparkExecutor.main(SparkExecutor.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.spark.deploy.yarn.ApplicationMaster$$anon$4.run(ApplicationMaster.scala:721)
问题是HBase-Spark-2.0.0-alpha4版本使用了Spark Logging类,而Spark 2.3.1中已弃用该类。
有人可以帮我解决这个问题吗?
注意:我正在使用Spark 2.3.1和HBase 1.2.6.1
答案 0 :(得分:1)
我正在使用Spark 2.2.x,但遇到了相同的问题。我忘记了我设法摆脱了以下哪些依赖关系,但是看到配置中缺少哪个依赖关系并尝试添加它。我应该工作。我相信那是火花流:
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.11</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>${hbase.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-spark</artifactId>
<version>${hbase-spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-mapreduce</artifactId>
<version>${hbase-spark.version}</version>
</dependency>
答案 1 :(得分:0)
到目前为止,我可以使用https://mvnrepository.com/artifact/org.apache.hbase.connectors.spark/hbase-spark/1.0.0
上的版本来解决它<!-- https://mvnrepository.com/artifact/org.apache.hbase.connectors.spark/hbase-spark -->
<dependency>
<groupId>org.apache.hbase.connectors.spark</groupId>
<artifactId>hbase-spark</artifactId>
<version>1.0.0</version>
</dependency>