Raymond Mogg
Raymond Mogg

Reputation: 192

Node Driver startup issue V1

I am running into an issue after upgrading a custom cordapp from M13 to V1. I have a small test suite which launches nodes using the node driver, and after upgrading to version 1 I get an issue which seems to be caused by the cordadevcakeys.jks file being null (see the error stack below). To upgrade I simply changed the build gradle release version and gradle plugins version from 0.13.0 to 1.0.0 - I am not sure if there is a step I am missing here that could potentially cause this error? I have also pulled the latests version 1 Corda project locally - although I was under the impression that this step isnt needed.

[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)

I can post the code I am using to launch the driver if need be, but by having a look at the cordapp-example it seems my method for starting the driver and nodes is correct, and it was working on M13.

*Edit, added in my gradle build and node driver code

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"
    }
}  

and this is my node driver code

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()
        }

Upvotes: 0

Views: 497

Answers (1)

Joel
Joel

Reputation: 23140

You need to close IntelliJ and clear out your gradle cache (under ~/.gradle on Mac).

Upvotes: 0

Related Questions