【问题标题】:Bouncy castle no such method error充气城堡没有这种方法错误
【发布时间】: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()) &gt;= 0) { if (c == '-' &amp;&amp; (last == 0 || last == '\n' || last == '\r')) { headerFound = true; break; } last = c; } }
  • 这段代码在 ArmoredInputStream 类中。Strings 和 StringList 两个类都是 Bouncy Castle 依赖项的一部分
  • edit您的问题以适当的格式包含代码。另外,你为什么要复制课程?您应该在类路径中包含 bouncycastle jar 并导入缺少的类。

标签: encryption bouncycastle


【解决方案1】:

该错误很可能发生,因为您在使用 Eclipse 运行时使用了一个版本的 bouncycastle .jar,但是在运行您的应用程序时 Weblogic 使用的类路径中存在其中一个 .jar 的不同版本.

您将需要调查 Weblogic 是如何准确设置类路径的,并确保您需要的 .jar 版本位于类路径中的先前版本之前(除非该预先存在的版本是错误的,在这种情况下,您可以只需从类路径中删除预先存在的那个)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-20
    • 1970-01-01
    • 1970-01-01
    • 2017-08-21
    • 1970-01-01
    • 1970-01-01
    • 2014-09-19
    相关资源
    最近更新 更多