Hello I am using Paytm checksum dependency in my Liferay dxp project
But I am getting error :com.sun.crypto.provider.AESCipher$General cannot be cast to javax.crypto.CipherSpi
Gradle Properties :
dependencies {compile fileTree(dir: 'libs/', include: '*.jar') compileInclude name: 'paytmchecksum-1.1'}
PaytmUtil contains the bellow code.
private static String getCheckSumPayTm(TreeMap<String, String> reqMap){
CheckSumServiceHelper checkSumServiceHelper = CheckSumServiceHelper.getCheckSumServiceHelper();
String checksum = null;
try {
checksum = checkSumServiceHelper.genrateCheckSum("paytmKey", reqMap.toString());
log.info("PAYTM CHECKSUM ================== " + checksum);
} catch (Exception e) {
e.printStackTrace();
log.error("error :" + e.getMessage());
}
return checksum;
}
Assuming that according to the static class hierarchy, you'd expect com.sun.crypto.provider.AESCipher$General
to be a valid subclass of javax.crypto.CipherSpi
, you're dealing with duplicate classes on the classpath - however you get them.
compileInclude is a good candidate for including more code than you want to on the classpath, i.e. duplicating classes that otherwise would come through the regular classloading mechanism.
What this error message unfortunately doesn't tell you is the classloader that loads each mentioned class. And most likely it's the superclass that's duplicate. You typically can read the error message as
com.sun.crypto.provider.AESCipher$General
cannot be cast tojavax.crypto.CipherSpi
loaded from classloader A - however, it could be cast tojavax.crypto.CipherSpi
from classloader B.
Unfortunately, in this case, you'll have to find classloaders A and B for yourself, but if you look for the location of CipherSpi
anywhere on your classpath, you should be able to find it. It's typically already provided and you shouldn't bring it yourself.