测试失败,出现NoClassDefFoundError:kotlin / AutoCloseableKt

时间:2019-01-28 14:45:26

标签: gradle kotlin corda

最近我的测试开始失败,出现了一个奇怪的NoClassDefFoundError: kotlin/AutoCloseableKt。此类包含2个内联实用程序方法,并且是kotlin-stdlib-jre7兼容性软件包的一部分。我使用JVM 1.8。此外,该项目不适用于AutoClosable

这可能是什么原因?

我使用Corda框架,最近我还添加了对Koin的依赖(如果有帮助的话)

例外:

kotlin/AutoCloseableKt
java.lang.NoClassDefFoundError: kotlin/AutoCloseableKt
    at net.corda.node.internal.cordapp.CordappLoader$Companion$createDevCordappJar$1.apply(CordappLoader.kt:150)
    at net.corda.node.internal.cordapp.CordappLoader$Companion$createDevCordappJar$1.apply(CordappLoader.kt:59)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at net.corda.node.internal.cordapp.CordappLoader$Companion.createDevCordappJar(CordappLoader.kt:143)
    at net.corda.node.internal.cordapp.CordappLoader$Companion.access$createDevCordappJar(CordappLoader.kt:59)
    at net.corda.node.internal.cordapp.CordappLoader$Companion$getPackageURLs$1.invoke(CordappLoader.kt:135)
    at net.corda.node.internal.cordapp.CordappLoader$Companion$getPackageURLs$1.invoke(CordappLoader.kt:59)
    at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:174)
    at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:691)
    at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(_Sequences.kt:721)
    at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:712)
    at net.corda.node.internal.cordapp.CordappLoader$Companion.getPackageURLs(CordappLoader.kt:138)
    at net.corda.node.internal.cordapp.CordappLoader$Companion.createDefaultWithTestPackages(CordappLoader.kt:100)
    at net.corda.testing.node.internal.InProcessNode.<init>(NodeBasedTest.kt:134)
    at net.corda.testing.node.internal.DriverDSLImpl$Companion$startInProcessNode$1.invoke(DriverDSLImpl.kt:805)
    at net.corda.testing.node.internal.DriverDSLImpl$Companion$startInProcessNode$1.invoke(DriverDSLImpl.kt:767)
    at net.corda.core.internal.concurrent.ValueOrException$DefaultImpls.capture(CordaFutureImpl.kt:107)
    at net.corda.core.internal.concurrent.OpenFuture$DefaultImpls.capture(CordaFutureImpl.kt)
    at net.corda.core.internal.concurrent.CordaFutureImpl.capture(CordaFutureImpl.kt:119)
    at net.corda.core.internal.concurrent.CordaFutureImplKt$fork$$inlined$also$lambda$1.run(CordaFutureImpl.kt:22)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: kotlin.AutoCloseableKt
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 27 more

我的./gradle dependencies

https://scans.gradle.com/s/bta3ize65pnc4/dependencies?toggled=W1sxXSxbMSwyMDhdXQ

1 个答案:

答案 0 :(得分:1)

这是由版本偏斜引起的。您可以尝试使用以下依赖项重新编译CorDapp吗?

compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"