1

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;
}
pratik patel
  • 306
  • 5
  • 16

1 Answers1

0

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 to javax.crypto.CipherSpi loaded from classloader A - however, it could be cast to javax.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.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • Hello, How can I find that in gradle? I am using "ibmjceProvider.jar" and java8 jre also contains "sunjce_provider". I think issue is there. not sure. need you guidance. – Purvesh Kachhiya Mar 28 '20 at 06:31
  • You'll find the duplications in the runtime system - then figure out where they're coming from in gradle. But the runtime would be the first place to look for anything. – Olaf Kock Mar 28 '20 at 09:37