Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

427
Visualizações
'class "org.bouncycastle.asn1.ASN1Primitive"'s signer information does not match signer information of other classes in the same package' using Itext

I'm developing a little tool to watermark PDFs and it works for some PDFs and crashes for some others.

I'm using iText library and bouncycastle (dependency)

pom.xml:

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

It crashes at this line (the very first line of code):

PdfReader reader = new PdfReader(src);

With the following stacktrace:

Exception in thread "main" com.itextpdf.text.exceptions.InvalidPdfException: class "org.bouncycastle.asn1.ASN1Primitive"'s signer information does not match signer information of other classes in the same package
at com.itextpdf.text.pdf.PdfReader.readPdf(PdfReader.java:727)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:181)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:219)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:207)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:197)
... <from here it points to my code>

I've done some googling and some people say that possibly the problem is that I have this bouncycastle lib duplicated somewhere.

This is inside an Spring application build with Maven. So, can this really be a library problem?

I'm using JDK 1.8.

What I've tried:

  • Different bouncycastle versions with Maven.
  • Different bouncycastle versions (supporting my JDK version) added manually to the project (including iText).

But the behaviour is exactly the same, some PDF works (always) and some others don't (ever).

Have you ever experienced any problem similar to this one using iText library?

Is the problem at the PDF files that make the code crash and not in my project?

I'm completely stuck here so any help/tip would be appreciated. Thanks in advance.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Thanks to Bruno Lowagie comments and linked question and mkl tip I've found the problem.

In my build path there were two org.bouncycastle libs, one I added via Maven (bcprov-jdk15on.jar) and another one used by Pivotal TC Server (com.springsource.org.bouncycastle.jce-1.46.0.jar).

I've removed the Pivotal TC Server bouncycastle jar and the error has gone away.

Pivotal bouncycastle jar was there

Using STS I was unable to remove it, so I found it on the filesystem and moved from the folder Pivotal TC expected it to be. Then, the lib disappeared at STS.

I haven't removed it just in case, only moved to another directory. If I have problems with Pivotal TC from now on I will update my answer.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda