Corda-无法初始化主类胶囊(引起原因:java.lang.NoClassDefFoundError:java / lang / instrument / Instrumentation)

时间:2018-09-18 14:28:41

标签: java corda

我正在尝试通过Corda Hello world example(特别是Java版本)。
我到了nodes should be deployed的地步,但失败了:

> ./gradlew clean deployNodes                    

> Configure project :
Gradle now uses separate output directories for each JVM language, but this build assumes a single directory for all classes from a source set. This behaviour has been deprecated and is scheduled to be removed in Gradle 5.0
        at build_9ngc7dap6wdyi5igmry41f6s9$_run_closure5.doCall(/home/foo/cordapp-template-java/build.gradle:85)
The setTestClassesDir(File) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the setTestClassesDirs(FileCollection) method instead.
        at build_9ngc7dap6wdyi5igmry41f6s9$_run_closure5.doCall(/home/foo/cordapp-template-java/build.gradle:85)

> Task :deployNodes
Bootstrapping local network in /home/foo/cordapp-template-java/build/nodes
Node config files found in the root directory - generating node directories
Generating directory for Notary
Generating directory for PartyA
Generating directory for PartyB
Nodes found in the following sub-directories: [PartyB, PartyA, Notary]
Waiting for all nodes to generate their node-info files...


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':deployNodes'.
> Node in PartyB exited with 1 when generating its node-info - see logs in /home/foo/cordapp-template-java/build/nodes/PartyB/logs

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
15 actionable tasks: 15 executed

建议我在/home/foo/cordapp-template-java/build/nodes/PartyB/logs中查看日志,其中包含文件node-info-gen.log,其内容如下:

Error: Unable to initialize main class Capsule
Caused by: java.lang.NoClassDefFoundError: java/lang/instrument/Instrumentation

PartitionA和Notary日志中也存在相同的错误。

此错误可能是什么原因?

为确保我不会意外添加导致更改的更改,我删除了更改并按原样使用了模板项目:

> git status       
On branch release-V3
Your branch is up-to-date with 'origin/release-V3'.
nothing to commit, working directory clean

> git branch -v                           
* release-V3 c9eed90 Reducing dependency on Jitpack by depending on new repository that is a combination of corda-releases and corda-dependencies (#37)

我的环境

> java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.16.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

> lsb_release -a                                 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:    16.04
Codename:   xenial

我也尝试使用Oracle JDK,但结果完全相同。

> /usr/lib/jvm/java-8-oracle/bin/java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

2 个答案:

答案 0 :(得分:0)

在运行deployNodes时,我认为您不应该运行干净任务。

1. ./gradlew clean build
2../gradlew deployNodes

应该可以。

答案 1 :(得分:0)

我的环境似乎有问题。
重新安装Java后,问题消失了。