JDK升级后未加载gradle测试依赖项NoClassDefFoundError

时间:2018-10-19 07:05:08

标签: scala gradle scope dependencies noclassdeffounderror

从昨天开始,我收到一个奇怪的类路径错误-升级JDK之后:

IEnumerable<T>.ForEach

但是,在IntelliJ中它可以正常工作。 有关详细信息,请参见配置:

ForEach

可以在https://github.com/geoHeil/classpath-gradle-test-failures/blob/master/build.gradle处找到详细的配置:

  • git clone
  • 等级考试

java版本:

*NoClassDefFoundError*: org/apache/hadoop/hive/ql/session/SessionState when creating Hive client using classpath: file:/Users/geoheil/project/build/classes/java/test, file:/Users/geoheil/project/build/classes/scala/test/
    Please make sure that jars for your version of hive and hadoop are included in the paths passed to spark.sql.hive.metastore.jars.

1 个答案:

答案 0 :(得分:1)

项目编译步骤中的警告提示已使用Java 9+。有关新模块系统的详细信息,请参见此SO answer

设置了Java 8后,您的演示项目就可以正常运行,而Java 10会因您所描述的错误而失败。对于任何JDK 9+版本,我都会期望同样的错误。

Oracle JDK 8(1.8.0_181):

1ATC

JDK 10(10.0.2):

$ gradle clean test --console=plain -Dorg.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
> Task :clean
> Task :compileJava NO-SOURCE
> Task :compileScala NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :compileTestJava NO-SOURCE

> Task :compileTestScala
Pruning sources from previous analysis, due to incompatible CompileSetup.

> Task :processTestResources NO-SOURCE
> Task :testClasses

> Task :test
Discovery starting.
Discovery completed in 117 milliseconds.
Run starting. Expected test count is: 2
18/10/19 13:24:28 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
18/10/19 13:24:30 WARN SparkContext: Using an existing SparkContext; some configuration may not take effect.
Test2:
foo2
18/10/19 13:24:37 WARN ObjectStore: Version information not found in metastore. hive.metastore.schema.verification is not enabled so recording the schema version 1.2.0
18/10/19 13:24:37 WARN ObjectStore: Failed to get database default, returning NoSuchObjectException
18/10/19 13:24:37 WARN ObjectStore: Failed to get database global_temp, returning NoSuchObjectException
root
 |-- value: integer (nullable = false)

+-----+
|value|
+-----+
|    1|
|    2|
|    3|
|    4|
+-----+

- should test fine (7 seconds, 859 milliseconds)
hello
Test1:
foo
- should test fine (1 millisecond)
Run completed in 10 seconds, 497 milliseconds.
Total number of tests run: 2
Suites: completed 3, aborted 0
Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
All tests passed.

BUILD SUCCESSFUL in 18s
3 actionable tasks: 3 executed