That exception is thrown when you pass an invalid private key, with the wrong length, to web3j to sign the transaction. Take a look in the example below.
Working code (with valid private key):
BigInteger privateKey = new BigInteger("f9c8a5d689736d881cf9b4117bbae6d935b2368f8260a25677e35d4d1eea7231", 16);
BigInteger publicKey = new BigInteger("72445fcfdeb1fff79496d7ce66089d663ff90e26", 16);
ECKeyPair pair = new ECKeyPair(privateKey, publicKey);
pair.sign("".getBytes());
Same code using invalid private key (one more digit added) and throwing exactly the same exception as yours:
BigInteger privateKey = new BigInteger("f9c8a5d689736d881cf9b4117bbae6d935b2368f8260a25677e35d4d1eea7231a", 16);
BigInteger publicKey = new BigInteger("72445fcfdeb1fff79496d7ce66089d663ff90e26a", 16);
ECKeyPair pair = new ECKeyPair(privateKey, publicKey);
pair.sign("".getBytes());
Always check if the private key and address are valid using WalletUtils.isValidPrivateKey() and WalletUtils.isValidAddress()