Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bouncy castle no such method error

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

like image 207
user3014515 Avatar asked May 26 '26 22:05

user3014515


1 Answers

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

like image 82
dan.m was user2321368 Avatar answered May 28 '26 10:05

dan.m was user2321368



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!