gpt4 book ai didi

java - 'class "org.bouncycaSTLe.asn1.ASN1Primitive"'s signer information does not match signer information of other classes in the same package' 使用 Itext

转载 作者:搜寻专家 更新时间:2023-11-01 02:58:46 31 4
gpt4 key购买 nike

我正在开发一个给 PDF 加水印的小工具,它适用于某些 PDF,但对某些其他 PDF 会崩溃。

我正在使用 iText 库和 bouncycaSTLe(依赖项)

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>

它在这一行(代码的第一行)崩溃:

PdfReader reader = new PdfReader(src);

使用以下堆栈跟踪:

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>

我做了一些谷歌搜索,有些人说可能的问题是我在某处复制了这个bouncycaSTLe lib

这是在使用 Maven 构建的 Spring 应用程序中。那么,这真的是图书馆的问题吗?

我正在使用 JDK 1.8

我尝试过的:

  • 使用 Maven 的不同 bouncycaSTLe 版本。
  • 不同的 bouncycaSTLe 版本(支持我的 JDK 版本)手动添加到项目(包括 iText)。

但行为完全相同,一些 PDF 有效(总是)而另一些 (永远).

您在使用 iText 库时是否遇到过与此类似的问题?

问题导致代码崩溃的PDF文件而不是在我的项目中?

我完全被困在这里,所以任何帮助/提示将不胜感激。提前致谢。

最佳答案

感谢 Bruno Lowagie 的评论和相关问题以及mkl 提示,我找到了问题。

在我的构建路径中,有两个 org.bouncycaSTLe 库,其中一个是我通过 Maven 添加的(bcprov-jdk15on.jar ) 和 Pivotal TC Server 使用的另一个 (com.springsource.org.bouncycaSTLe.jce-1.46.0.jar)。

我已经删除 Pivotal TC Server bouncycaSTLe jar 并且错误已经消失。。 p>

Pivotal bouncycastle jar was there

使用 STS 我无法删除它,所以我在文件系统上找到它并从 Pivotal TC 预期的文件夹中移出。然后,这个lib在STS就消失了。

我没有删除它以防万一,只是移动到另一个目录。如果我从现在开始在使用 Pivotal TC 时遇到问题,我会更新我的答案。

关于java - 'class "org.bouncycaSTLe.asn1.ASN1Primitive"'s signer information does not match signer information of other classes in the same package' 使用 Itext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43213776/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com