节点驱动程序启动问题 V1



我将自定义 cordapp 从 M13 升级到 V1 后遇到了问题。我有一个小型测试套件,它使用节点驱动程序启动节点,升级到版本 1 后,我遇到了一个问题,该问题似乎是由 cordadevcakeys.jks 文件为空引起的(请参阅下面的错误堆栈(。要升级,我只是将构建 gradle 发布版本和 gradle 插件版本从 0.13.0 更改为 1.0.0 - 我不确定我这里是否缺少可能导致此错误的步骤?我还在本地拉取了最新的版本 1 Corda项目 - 尽管我的印象是不需要这一步。

[ERROR] 12:45:26,017 [main] (Driver.kt:396) driver.DriverDSL.genericDriver - 
Driver shutting down because of exception
java.lang.ExceptionInInitializerError: null
at net.corda.testing.driver.DriverDSL.start(Driver.kt:796) ~[corda-node-driver-1.0.0.jar:?]
at net.corda.testing.driver.Driver.genericDriver(Driver.kt:393) [corda-node-driver-1.0.0.jar:?]
at net.corda.testing.driver.Driver.driver(Driver.kt:317) [corda-node-driver-1.0.0.jar:?]
at net.corda.testing.driver.Driver.driver$default(Driver.kt:314) [corda-node-driver-1.0.0.jar:?]
at src.DeploymentTestKt.main(DeploymentTest.kt:29) [main/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:65) [idea_rt.jar:?]
Caused by: java.lang.IllegalStateException: ClassLoader.getSystemRes…ates/cordadevcakeys.jks") must not be null
at net.corda.testing.TestConstants$DEV_CA$2.invoke(TestConstants.kt:72) ~[corda-test-utils-1.0.0.jar:?]
at net.corda.testing.TestConstants$DEV_CA$2.invoke(TestConstants.kt) ~[corda-test-utils-1.0.0.jar:?]
at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130) ~[kotlin-stdlib-1.1.4.jar:1.1.4]
at net.corda.testing.TestConstants.getDEV_CA(TestConstants.kt) ~[corda-test-utils-1.0.0.jar:?]
at net.corda.testing.CoreTestUtils.getTestPartyAndCertificate$default(CoreTestUtils.kt:145) ~[corda-test-utils-1.0.0.jar:?]
at net.corda.testing.CoreTestUtils.getBOC_IDENTITY(CoreTestUtils.kt:75) ~[corda-test-utils-1.0.0.jar:?]
at net.corda.testing.CoreTestUtils.getBOC(CoreTestUtils.kt:76) ~[corda-test-utils-1.0.0.jar:?]
at net.corda.testing.CoreTestUtils.<clinit>(CoreTestUtils.kt:77) ~[corda-test-utils-1.0.0.jar:?]
... 10 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
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 com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:65)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.corda.testing.CoreTestUtils
at net.corda.testing.driver.ShutdownManager.shutdown(Driver.kt:505)
at net.corda.testing.driver.DriverDSL.shutdown(Driver.kt:627)
at net.corda.testing.driver.Driver.genericDriver(Driver.kt:399)
at net.corda.testing.driver.Driver.driver(Driver.kt:317)
at net.corda.testing.driver.Driver.driver$default(Driver.kt:314)
at src.DeploymentTestKt.main(DeploymentTest.kt:29)
... 5 more
Exception in thread "Thread-1" java.lang.NoClassDefFoundError: Could not initialize class net.corda.testing.CoreTestUtils
at net.corda.testing.driver.ShutdownManager.shutdown(Driver.kt:505)
at net.corda.testing.driver.DriverDSL.shutdown(Driver.kt:627)
at net.corda.testing.driver.Driver$genericDriver$shutdownHook$1.invoke(Driver.kt:391)
at net.corda.testing.driver.Driver$genericDriver$shutdownHook$1.invoke(Driver.kt)
at net.corda.nodeapi.internal.ShutdownHookKt$addShutdownHook$hook$1.run(ShutdownHook.kt:15)
at java.lang.Thread.run(Thread.java:748)

如果需要,我可以发布用于启动驱动程序的代码,但是通过查看cordapp示例,似乎我启动驱动程序和节点的方法是正确的,并且它在M13上工作。

*编辑,添加到我的 gradle 构建和节点驱动程序代码中

apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'idea'
apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'net.corda.plugins.cordformation'
apply plugin: 'maven-publish'
apply plugin: 'application'
apply plugin: 'net.corda.plugins.quasar-utils'
repositories {
    mavenLocal()
    jcenter()
    mavenCentral()
    maven { url 'https://dl.bintray.com/kotlin/exposed' }
    maven { url 'https://jitpack.io' }
}
sourceSets {
    main {
        resources {
            srcDir "../config/dev"
        }
    }
    test {
        resources {
            srcDir "../config/test"
        }
    }
}
dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
    compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
    compileOnly "co.paralleluniverse:capsule:1.0.1"
    compile 'net.sourceforge.plantuml:plantuml:8039'
    testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
    testCompile "junit:junit:$junit_version"
    //Corda integration dependencies
    cordaCompile "net.corda:corda-core:$corda_release_version"
    cordaCompile "net.corda:corda-finance:$corda_release_version"
    cordaCompile "net.corda:corda-jackson:$corda_release_version"
    cordaCompile "net.corda:corda-jfx:$corda_release_version"
    cordaCompile "net.corda:corda-rpc:$corda_release_version"
    cordaCompile "net.corda:corda-node-api:$corda_release_version"
    cordaCompile "net.corda:corda-webserver-impl:$corda_release_version"
    cordaCompile "net.corda:corda-test-utils:$corda_release_version"
    testCompile "net.corda:corda-test-utils:$corda_release_version"
    cordaRuntime "net.corda:corda:$corda_release_version"
    cordaRuntime "net.corda:corda-webserver:$corda_release_version"
    cordaCompile "net.corda:corda-node-driver:$corda_release_version"
    //testCompile "net.corda:corda-node-driver:$corda_release_version"
    cordapp "net.corda:corda-finance:$corda_release_version"
//    cordaCompile "net.corda:corda-core:$corda_release_version"
//    cordaCompile "net.corda:corda-finance:$corda_release_version"
//    cordaCompile "net.corda:corda-jackson:$corda_release_version"
//    cordaCompile "net.corda:corda-rpc:$corda_release_version"
//    cordaCompile "net.corda:corda-node-api:$corda_release_version"
//    cordaCompile "net.corda:corda-webserver-impl:$corda_release_version"
//    cordaRuntime "net.corda:corda:$corda_release_version"
//    cordaRuntime "net.corda:corda-webserver:$corda_release_version"
//    testCompile "net.corda:corda-test-utils:$corda_release_version"
//    cordaCompile "net.corda:corda-node-driver:$corda_release_version"
//    testCompile "net.corda:corda-node-driver:$corda_release_version"

}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        languageVersion = "1.1"
        apiVersion = "1.1"
        jvmTarget = "1.8"
        javaParameters = true   // Useful for reflection.
    }
}
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
    directory "./build/nodes"
    networkMap "CN=Controller,O=R3,OU=corda,L=London,C=UK"
    node {
        name "CN=Controller,O=R3,OU=corda,L=London,C=UK"
        advertisedServices = ["corda.notary.validating"]
        p2pPort 10002
        rpcPort 10003
        cordapps = ["secLendModel"]
    }
    node {
        name "CN=NodeA,O=NodeA,L=London,C=UK"
        advertisedServices = []
        p2pPort 10005
        rpcPort 10006
        webPort 10007
        cordapps = ["secLendModel"]
        rpcUsers = [[ user: "user1", "password": "test", "permissions": []]]
    }
    node {
        name "CN=NodeB,O=NodeB,L=New York,C=US"
        advertisedServices = []
        p2pPort 10008
        rpcPort 10009
        webPort 10010
        cordapps = ["secLendModel"]
        rpcUsers = [[ user: "user1", "password": "test", "permissions": []]]
    }
    node {
        name "CN=NodeC,O=NodeC,L=Paris,C=FR"
        advertisedServices = []
        p2pPort 10011
        rpcPort 10012
        webPort 10013
        cordapps = ["secLendModel"]
        rpcUsers = [[ user: "user1", "password": "test", "permissions": []]]
    }
}
// TODO: Make into gradle plugin without any references to Jython
task installJythonDeps(dependsOn: ['build']) {
    project.copy {
        from project.configurations.runtime
        into "build/jythonDeps"
    }
}
installJythonDeps.shouldRunAfter build
idea {
    module {
        downloadJavadoc = true // defaults to false
        downloadSources = true
    }
}
publishing {
    publications {
        jarAndSources(MavenPublication) {
            from components.java
            artifactId 'secLendModel'
            artifact sourceJar
            artifact javadocJar
        }
    }
}
task runTemplateClientRPC(type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    main = 'com.template.client.TemplateClientRPCKt'
    args 'localhost:10006'
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}  

这是我的节点驱动程序代码

fun runSimulation() {
        driver(portAllocation = PortAllocation.Incremental(20000), isDebug = false, startNodesInProcess = true, extraCordappPackagesToScan = listOf("com.secLendModel")) {
            //Normal Users
            val arnoldParams = NodeParameters(providedName = ARNOLD, rpcUsers = arrayListOf(stdUser))
            val barryParams = NodeParameters(providedName = BARRY, rpcUsers = arrayListOf(stdUser))
            val colinParams = NodeParameters(providedName = COLIN, rpcUsers = arrayListOf(stdUser))
            val arnold = startNode(defaultParameters = arnoldParams)
            val barry = startNode(defaultParameters = barryParams)
            val colin = startNode(defaultParameters = colinParams)
            //Special Users (i.e asset issuers and oracles)
            val notaryParams = NodeParameters(providedName = NOTARY, advertisedServices = setOf(ServiceInfo(ValidatingNotaryService.type)))
            val notary = startNode(defaultParameters = notaryParams)
            //Stock issuer AND stock price oracle
            val exchangeParams = NodeParameters(providedName = EXCHANGE, rpcUsers = arrayListOf(specialUser),
                    advertisedServices = MARKET.plus(ServiceInfo(PriceType.type)))
            val exchange = startNode(defaultParameters = exchangeParams)
            //Cash issuer
            val centralbankParams = NodeParameters(providedName = CENTRALBANK, rpcUsers = arrayListOf(specialUser),
                    advertisedServices = CURRENCIES)
            val centralBank = startNode(defaultParameters = centralbankParams)
//            val oracle = startNode(ORACLE, advertisedServices = setOf(ServiceInfo(PriceType.type)))
            notaryNode = notary.get()
            arnoldNode = arnold.get()
            barryNode = barry.get()
            colinNode = colin.get()
            exchangeNode = exchange.get()
            centralNode = centralBank.get()
//            oracleNode = oracle.get()
            startWebserver(arnoldNode)
            setUpNodes()
            simulateTransactions()
            waitForAllNodesToFinish()
        }

您需要关闭 IntelliJ 并清除您的 gradle 缓存(在 Mac 上的 ~/.gradle 下(。

最新更新