Skip to content

static block in Password class does not initialize due to NPE #120

@divijen

Description

@divijen

Issue Description:
Application throws a NoClassDefFoundError for Password class even though it is present in the final application build.

Steps to reproduce:
Simply use the Password class to create an scrypt hash as mentioned in the password4j getstarted page.

Expected behavior:
Generate a hash without Exception.

Environment:

  • OS: mxlinux
  • JDK Amazon Corretto
  • Version 8
  • enterprise ear file deployed on wildfly server

Additional context:
This is happening because the static block of Password.java is not loading due to an eventual NPE that occurs in the library code. This in turn stops this class from loading and manifests as a java.lang.NoClassDefFoundError in the application.

Please confirm if this is an issue or requires any configuration change.

Exception stack trace:
Caused by: java.lang.NullPointerException
at com.password4j.AlgorithmFinder.getAllPBKDF2Variants(AlgorithmFinder.java:346)
at com.password4j.Utils.printBanner(Utils.java:582)
at com.password4j.Password.(Password.java:37)

Problem in line number 346 of AlgorithmFinder class. The provider creating the problem is ThreadLocalSecurityProvider. The size says 4 but returns null.
image
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions