Skip to main content
Skip table of contents

Why do I get a BouncyCastle NoClassDefFoundError?

I want to encrypt my PDF but there seems to be an error.

Here is the code:

PdfReader reader = new PdfReader("my.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("new.pdf"));
stamper.setEncryption("reader_password".getBytes(), "permission_password".getBytes(),
Here's the error I get:

Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1Encodable

Posted on StackOverflow on May 19, 2014 by wizclark99

When you look at the POM file for iText, you see the following dependencies:


This means that you need the bcprov and the bcpkix jars version 1.49 from Bouncycastle.

If you are not using iText 5.5.x, please check the POM file as older version of iText might require older versions of BouncyCastle.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.