Resolving NoClassDefFoundError: org/apache/spark/Logging exception
Resolving NoClassDefFoundError: org/apache/spark/Logging exception
我正在试用 hbase-spark 连接器。首先,我正在尝试 this 代码。
我的 pom 依赖项是:
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-spark</artifactId>
<version>2.0.0-alpha4</version>
</dependency>
</dependencies>
我在 运行 代码时遇到以下异常:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/Logging
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access0(URLClassLoader.java:73)
at java.net.URLClassLoader.run(URLClassLoader.java:368)
at java.net.URLClassLoader.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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.hadoop.hbase.spark.JavaHBaseContext.(JavaHBaseContext.scala:46)
at com.myproj.poc.sparkhbaseneo4j.App.main(App.java:71)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.Logging
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 14 more
com.myproj.poc.sparkhbaseneo4j.App.main(App.java:71)
是 github 代码中的 line 67。
我检查了 。它说我应该包含所有库的相同版本。早些时候,我的 pom.xml 中有 2.3.0 版本的 spark 库。但我意识到 hbase-spark
有最新版本 2.0.0
。所以我将所有 spark 库的版本降级为 2.0.0
。但我仍然遇到同样的异常。
或者我是否必须坚持使用 1.X.X
版本才能使用它,因为 答案说它在 1.5.2 版本之后被删除了?
Sean Owen 在 http://community.cloudera.com/t5/Advanced-Analytics-Apache-Spark/Hit-quot-Exception-in-thread-main-java-lang-NoClassDefFoundError/td-p/44486 中建议 "You shouldn't use org.apache.spark.Logging in your app at all. That's likely the problem and solution."
所以你应该使用下面的或者higher version
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
已更新
I specified that and now I am getting NoClassDefFoundError: org/apache/spark/streaming/dstream/DStream
对于上述问题你需要以下依赖
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-streaming -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.11</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
我正在试用 hbase-spark 连接器。首先,我正在尝试 this 代码。
我的 pom 依赖项是:
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-spark</artifactId>
<version>2.0.0-alpha4</version>
</dependency>
</dependencies>
我在 运行 代码时遇到以下异常:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/Logging at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access0(URLClassLoader.java:73) at java.net.URLClassLoader.run(URLClassLoader.java:368) at java.net.URLClassLoader.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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.apache.hadoop.hbase.spark.JavaHBaseContext.(JavaHBaseContext.scala:46) at com.myproj.poc.sparkhbaseneo4j.App.main(App.java:71) Caused by: java.lang.ClassNotFoundException: org.apache.spark.Logging at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 14 more
com.myproj.poc.sparkhbaseneo4j.App.main(App.java:71)
是 github 代码中的 line 67。
我检查了 hbase-spark
有最新版本 2.0.0
。所以我将所有 spark 库的版本降级为 2.0.0
。但我仍然遇到同样的异常。
或者我是否必须坚持使用 1.X.X
版本才能使用它,因为
Sean Owen 在 http://community.cloudera.com/t5/Advanced-Analytics-Apache-Spark/Hit-quot-Exception-in-thread-main-java-lang-NoClassDefFoundError/td-p/44486 中建议 "You shouldn't use org.apache.spark.Logging in your app at all. That's likely the problem and solution."
所以你应该使用下面的或者higher version
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
已更新
I specified that and now I am getting NoClassDefFoundError: org/apache/spark/streaming/dstream/DStream
对于上述问题你需要以下依赖
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-streaming -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.11</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>