mlee_jordan
mlee_jordan

Reputation: 842

I am getting java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1Primitive error

I want to download and convert pdf files into plain text by using itextpdf.5.4.1. For most of them my code works but for one of them I encountered the error below when I try to read the file.

PdfReader reader = new PdfReader(pdf_file_path);


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

Does it mean that this pdf is protected and there is no way to extract the text?

Upvotes: 1

Views: 17136

Answers (2)

Sushank Dahiwadkar
Sushank Dahiwadkar

Reputation: 93

I was also facing the same problem while reading pdf uing itext 5.5.10.

I changed the dependancies to following :

    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itextpdf</artifactId>
        <version>5.5.4</version>
    </dependency>
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk15on</artifactId>
        <version>1.49</version>
    </dependency>
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcpkix-jdk15on</artifactId>
        <version>1.49</version>
    </dependency>

You can also refer : https://stackoverflow.com/a/27575336/3150912

Upvotes: 5

Alex Gorbunov
Alex Gorbunov

Reputation: 239

That's cause of different versions of itext in your project. Please, check out your dependencies in your build file.

Upvotes: 0

Related Questions