m00*_*00h 11 pdf-generation bouncycastle itext
我们有一个创建PDFs unsing jasperreports的应用程序.
它还在创建后使用iText操纵所述PDF.
我们最近开始在某些PDF上使用加密.这意味着在应用程序创建后可以处理PDF之前,必须对其进行解密.尝试使用iText时,PdfReader(String path, byte[] password)我得到以下异常:
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)
Run Code Online (Sandbox Code Playgroud)
该项目使用Maven构建为可运行的.jar,并使用以下依赖项:
iText 5.4.2
bouncycastle 1.48
我应该提一下,jasperreports有自己的iText和bouncycastle依赖:
iText 2.1.7
bouncycastle 1.38
我无法弄清楚发生了什么,需要帮助.
Mar*_*nik 27
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.