Bouncy castle no such method error

余生长醉 提交于 2020-01-24 13:05:33

问题


I'm trying to decrypt a file using Bouncy Castle v1.53 PGP and Using PGPUtil class. The program works fine in my Eclipse, but given following error when integrated inside a war file and deployed onto a weblogic server.I'm using following dependencies: 1)bcpg-jdk15on 2)bcprov-jdk15on

Error

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)`

Resolution

This problem is resolved when I copied following classes into my source folder:

org.bouncycastle.util.Strings  
org.bouncycastle.util.StringList  
org.bouncycastle.bcpg.ArmoredInputStream  
org.bouncycastle.openpgp.PGPUtil`

by changing their Class Names

However, I want a better fix than this as I feel this is some Jar Conflict Please let me know if anyone finds one


回答1:


That error is likely happening because you are using one version of the bouncycastle .jars when you run with Eclipse, but there is a different version of one of those .jars which is on the classpath that Weblogic is using when running your application.

You will need to investigate how exactly Weblogic sets up the classpath, and make sure the version of the .jars you need are on the classpath before the preexisting version (unless that preexisting version is there by mistake, in which case you can just remove the preexisting one from the classpath).



来源:https://stackoverflow.com/questions/34529351/bouncy-castle-no-such-method-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!