Class.getResourceAsStream() returns null
when there is no resource with the specified name.
KeyStore.load() resets the key store to the empty state when passed a null
input stream.
It means that at runtime your code does not find the keystore resource and silently proceeds with the empty keystore.
- add a guarding condition that checks that
getResourceAsStream()
returned non-null value before passing it value intoKeyStore.load()
. - review your code and building/packaging process in maven to ensure that keystore file is present at the proper location.
There are some questions about getResourceAsStream()
that can be of help for you.