Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException upon moving to 4.7.6 from 4.7.5 #2291

Open
JessHolle opened this issue May 28, 2024 · 2 comments
Open

NullPointerException upon moving to 4.7.6 from 4.7.5 #2291

JessHolle opened this issue May 28, 2024 · 2 comments
Milestone

Comments

@JessHolle
Copy link

I am getting a NullPointerException apparently from within picocli code when attempting to upgrade to 4.7.6 from 4.7.5 (where the app works AOK).

I get

NullPointerException: Cannot invoke "java.lang.ClassLoader.getResource(String)" because the return value of "java.lang.Class.getClassLoader()" is null while processing argument at or before arg[2] 'foo' in [dumpSchema, -o, foo]: java.lang.NullPointerException: Cannot invoke "java.lang.ClassLoader.getResource(String)" because the return value of "java.lang.Class.getClassLoader()" is null

The related annotations are:

  @CommandLine.Command(name = "dumpSchema", separator = " ", description="...",
                       mixinStandardHelpOptions = true, versionProvider = Main.VersionProvider.class,
                       defaultValueProvider = PropertiesDefaultProvider.class)
  // used from main() via picocli annotations
  private static void dumpSchema(
    @CommandLine.Option(names = "-o", paramLabel="<outputFile>", required = false,
                        description = "...")
    @Nullable Path outputFile)

Setting -Dpicocli.trace, I get loads of INFO messages along these lines. All without any further stack traces or the like, unfortunately.

With 4.7.5 I get no such messages.

In case it matters this is for an application wrapped up as a single jar and being invoked via java -jar (and built via the com.github.johnrengelman.shadow Gradle plugin).

@remkop
Copy link
Owner

remkop commented May 29, 2024

Thank you for raising this.
Class.getClassLoader() returning null is puzzling, to say the least, but the fact that you don't see this with picocli 4.7.5 suggests that it is related to a recent change.

This may be difficult to investigate without a way to reproduce the issue. Is your application in a public repo somewhere?

@remkop
Copy link
Owner

remkop commented May 29, 2024

I think I found the cause:
The change in #2107 (PropertiesDefaultProvider improvement) is missing some defensive coding.

@remkop remkop added this to the 4.7.7 milestone May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants