question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullpointerException in makeCordappLoader

See original GitHub issue

version 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:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
r3jirabotcommented, Jun 8, 2020

Automatically created Jira issue: CORDA-3831

0reactions
remmeiercommented, Jun 17, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullPointerException in code created with jasmin bytecode ...
NullPointerException. I am attempting to compile a bit of code to the jvm and this is what my compiler outputs
Read more >
java.lang.NullPointerException when trying to compile
Hi everybody! I'm trying to compile a file using javax.tools.JavaCompiler but I get a java.lang.NullPointerException when running the program.
Read more >
Null Pointer Exception Java Fix - YouTube
Full Java Course: https://course.alexlorenlee.com/courses/learn-java-fastIf you want to be a Software Engineer, I HIGHLY RECOMMEND applying ...
Read more >
What is a NullPointerException, and how do I fix it? - YouTube
... and how do I fix it?# NullPointerException exception occurred when you are trying to get something from null referenced object...
Read more >
CCS: java.lang.NullPointerException when importing project
Tool/software: Code Composer Studio Hi, I am running CCS 5.5... When I try to import an existing code composer project, the import fails...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found