If you look at the API documentation of the
Cipher.doFinal() method, you'll find when it will throw a BadPaddingException:
if this cipher is in decryption mode, and (un)padding has been requested, but the decrypted data is not bounded by the appropriate padding bytes
When you retrieve an instance of Cipher for the AES algorithm, try explicitly providing the padding scheme, instead of relying on the default as you do now.
If no padding was used when the plaintext was encypted,
you should explicitly specify
NoPadding.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.