Reputation: 711
I have included 2 BC jars into my project: bcpkix-jdk15on-1.47.jar and bcprov-jdk15on-157.jar.
As the first line in code I have added:
Security.addProvider(new BouncyCastleProvider());
Exception occurs on the line:
JcaPKCS10CertificationRequest csrNew = new JcaPKCS10CertificationRequest(request);
By the way it is imported: import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest;
But I am still getting :
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/bouncycastle/jcajce/JcaJceHelper at implementation.Util.generateCSR(Util.java:396)
NetBeans found class regularly, but when I run project exception happens.
Is there any way how could I regularly include both of these two BouncyCastle jars?
Upvotes: 3
Views: 25760
Reputation: 1598
Error is coming for org/bouncycastle/jcajce/JcaJceHelper
, not for org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest
.
Problem: versions of jar files you are using. bcpkix-jdk15on-1.47
is version 1.47, whereas bcprov-jdk15on-1.57
is version 1.57.
org/bouncycastle/jcajce/JcaJceHelper
was available in bcprov-jdk15on-1.47
but it is not available in bcprov-jdk15on-1.57
. In version 1.57, it is available as org/bouncycastle/jcajce/util/JcaJceHelper
.
Netbeans is unable to detect the issue, because this issue would come only when you run the code. It will not be caught at compile time.
Solution:
Yes, you can use both jars together. Just use the same version. Either use bcpkix-jdk15on-1.57
OR use bcprov-jdk15on-1.47
.
Upvotes: 12