错误:com.sun.crypto.provider.AESCipher $ General无法转换为javax.crypto.CipherSpi [英] error :com.sun.crypto.provider.AESCipher$General cannot be cast to javax.crypto.CipherSpi
问题描述
你好,我在Liferay dxp项目中使用Paytm校验和依赖项
Hello I am using Paytm checksum dependency in my Liferay dxp project
但是我遇到了 error:com.sun.crypto.provider.AESCipher $ General无法转换为javax.crypto.CipherSpi
Gradle属性:
dependencies {compile fileTree(dir: 'libs/', include: '*.jar') compileInclude name: 'paytmchecksum-1.1'}
PaytmUtil包含以下代码.
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;
}
推荐答案
假设根据静态类层次结构,您希望 com.sun.crypto.provider.AESCipher $ General
为一个有效的 javax.crypto.CipherSpi
子类,您正在处理类路径上的重复类-但是会得到它们.
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是一个不错的选择,因为它可以在类路径上包含比您想要的更多的代码,即,复制类,否则这些类将通过常规的类加载机制来提供.
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
强制转换为从类加载器A加载的javax.crypto.CipherSpi
,但是可以从类加载器B强制转换为javax.crypto.CipherSpi
.
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.
不幸的是,在这种情况下,您必须自己找到类加载器A和B,但是如果您在类路径上的任何位置查找 CipherSpi
的位置,则应该能够找到它..通常已经提供了它,您不应该自己带它.
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.
这篇关于错误:com.sun.crypto.provider.AESCipher $ General无法转换为javax.crypto.CipherSpi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!