NullpointerException in makeCordappLoader
See original GitHub issueversion tried: 4.4 release and 4.5-SNAPSHOT
This bug seems a bit on the odd side of things, at least for a Kotlin newbie.
We I managed to get this exception:
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.corda.node.internal.cordapp.VirtualCordapp.generateCore(VirtualCordapps.kt:26)
at net.corda.node.internal.AbstractNode.makeCordappLoader(AbstractNode.kt:720)
at net.corda.node.internal.AbstractNode.<init>(AbstractNode.kt:241)
at net.corda.node.internal.AbstractNode.<init>(AbstractNode.kt:213)
at net.corda.node.internal.Node.<init>(Node.kt:129)
at net.corda.node.internal.Node.<init>(Node.kt:128)
at net.corda.node.internal.NodeStartup.createNode(NodeStartup.kt:204)
at net.corda.node.internal.NodeStartup$initialiseAndRun$5.invoke(NodeStartup.kt:196)
at net.corda.node.internal.NodeStartup$initialiseAndRun$5.invoke(NodeStartup.kt:142)
at net.corda.node.internal.NodeStartupLogging$DefaultImpls.attempt(NodeStartup.kt:536)
at net.corda.node.internal.NodeStartup.attempt(NodeStartup.kt:142)
at net.corda.node.internal.NodeStartup.initialiseAndRun(NodeStartup.kt:195)
at io.example.node.ExampleNode.run(ExampleNode.java:211)
at io.example.node.ExampleNode.start(ExampleNode.java:96)
at io.example.node.ExampleNode.main(ExampleNode.java:68)
Caused by: java.lang.NullPointerException
at net.corda.core.internal.cordapp.CordappImpl$Companion.jarName(CordappImpl.kt:50)
at net.corda.core.internal.cordapp.CordappImpl.<init>(CordappImpl.kt:41)
at net.corda.core.internal.cordapp.CordappImpl.<init>(CordappImpl.kt:39)
at net.corda.core.internal.cordapp.CordappImpl.<clinit>(CordappImpl.kt:73)
... 15 more
It is just a regular node startup where our ExampleNode
prepares two, three things before running Corda as in the official image.
the problematic part here is in VrirtualCordapp.generateCore
where a new CordappImpl
is created executing the following line:
override val name: String = jarName(jarPath)
There is a bit of initialization stuff going on in that class. with some fields depending on others. some things defined in the parent interface, others not. In this particular case it seems that name
can get initialized before jarPath
, resulting in the given exception as the name cannot be computed yet. To my suprise that is not deterministic. For us it worked well when running it directly out of the IDE and in Gradle. But not anymore in Docker. Maybe the operating system or JVM or another small thing triggered the change in behavior of Kotlin. But overall we make use of the same image as the official docker image.
we fixed it by modifying the line to:
override val name: String by lazy { jarName(jarPath) }
can do a PR if desired. Or can investigate further if desired.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Automatically created Jira issue: CORDA-3831
yes
TEST_INSTANCE
is causing the problem. I overlooked that initially.The fix is working, thx. Potentially you want to deprecate that field since it is testing code shipped with production code and only seems to be used in one place (MockCordappProvider).