本文介绍了iText / BouncyCastle抛出“java.lang.VerifyError:class overrides final method equals”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个应用程序可以创建PDF未发布的jasperreports。

它还在创建后使用iText操作所述PDF。

We have an application that creates PDFs unsing jasperreports.
It also manipulates said PDFs using iText after they have been created.

我们最近开始在某些PDF上使用加密。这意味着在应用程序创建后可以处理PDF之前,必须对其进行解密。尝试使用iText的 PdfReader(字符串路径,byte []密码)时,我得到以下异常:

We recently started using encryption on some PDF. That means before the app can handle the PDF after its creation, it has to be decrypted. While attempting to do so using iText's PdfReader(String path, byte[] password) I get the following exception:

java.lang.VerifyError: class org.bouncycastle.asn1.ASN1Primitive overrides final method equals.(Ljava/lang/Object;)Z
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at com.simontuffs.onejar.JarClassLoader.defineClass(JarClassLoader.java:561)
    at com.simontuffs.onejar.JarClassLoader.findClass(JarClassLoader.java:475)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at com.itextpdf.text.pdf.PdfEncryption.<init>(PdfEncryption.java:148)
    at com.itextpdf.text.pdf.PdfReader.readDecryptedDocObj(PdfReader.java:914)
    at com.itextpdf.text.pdf.PdfReader.readDocObj(PdfReader.java:1294)
    at com.itextpdf.text.pdf.PdfReader.readPdf(PdfReader.java:643)
    at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:187)
    at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:212)
    at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:202)

使用Maven将项目构建为可运行的.jar并使用以下依赖项:

iText 5.4.2

bouncycastle 1.48

The project is built as a runnable .jar using Maven and uses the following dependencies:
iText 5.4.2
bouncycastle 1.48

我应该提到jasperreports有自己的iText和bouncycastle依赖:

iText 2.1.7

bouncycastle 1.38

I should mention that jasperreports has its own dependency of iText and bouncycastle:
iText 2.1.7
bouncycastle 1.38

我无法弄清楚发生了什么,需要帮助。

I can't figure out what's going on on and need help.

推荐答案

我最好的猜测是你在类路径上最终得到了两个不同版本的Bouncy Castle,它发生了以致类加载器从一个版本加载了超类现在正试图从另一个加载子类。版本的不同之处在于其中一个版本定义了最终的equals方法。

My best guess is that you have ended up with two different versions of Bouncy Castle on your classpath, and it happened so that the classloader has loaded the superclass from one version and is now trying to load the subclass from the other. The versions are different in that one of them defines a final equals method.

这篇关于iText / BouncyCastle抛出“java.lang.VerifyError:class overrides final method equals”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:44