【发布时间】:2016-04-04 10:01:38
【问题描述】:
我正在尝试使用 Bouncy Castle v1.53 PGP 和使用 PGPUtil 类解密文件。 该程序在我的 Eclipse 中运行良好,但在集成到 war 文件中并部署到 weblogic 服务器时出现以下错误。我正在使用以下依赖项: 1)bcpg-jdk15on 2)bcprov-jdk15on
错误
java.lang.NoSuchMethodError:
org.bouncycastle.util.Strings.newList()Lorg/bouncycastle/util/StringList;
at org.bouncycastle.bcpg.ArmoredInputStream.<init>(Unknown Source)
at org.bouncycastle.bcpg.ArmoredInputStream.<init>(Unknown Source)
at org.bouncycastle.openpgp.PGPUtil.getDecoderStream(Unknown Source)`
分辨率
当我将以下类复制到我的源文件夹中时,此问题得到解决:
org.bouncycastle.util.Strings
org.bouncycastle.util.StringList
org.bouncycastle.bcpg.ArmoredInputStream
org.bouncycastle.openpgp.PGPUtil`
通过更改他们的类名
但是,我想要一个比这更好的解决方案,因为我觉得这是一些 Jar Conflict 如果有人找到请告诉我
【问题讨论】:
-
请提供一些代码...
-
boolean hasHeaders = true; String header = null; boolean newLineFound = false; boolean clearText = false; boolean restart = false; StringList headerList= Strings.newList();//error int lastC = 0; boolean isEndOfStream; private boolean parseHeaders() throws IOException { header = null; int c; int last = 0; boolean headerFound = false; headerList = Strings.newList();//error if (restart) { headerFound = true; } else { while ((c = in.read()) >= 0) { if (c == '-' && (last == 0 || last == '\n' || last == '\r')) { headerFound = true; break; } last = c; } } -
这段代码在 ArmoredInputStream 类中。Strings 和 StringList 两个类都是 Bouncy Castle 依赖项的一部分
-
请edit您的问题以适当的格式包含代码。另外,你为什么要复制课程?您应该在类路径中包含 bouncycastle jar 并导入缺少的类。