简体   繁体   English

NoClassDefFoundError:将jasper导出到pdf时com / itextpdf / text / DocumentException

[英]NoClassDefFoundError: com/itextpdf/text/DocumentException when exporting jasper to pdf

I created a jasper report and now I need to export that report to pdf format. 我创建了一个jasper报告,现在我需要将该报告导出为pdf格式。 This is my code for that. 这是我的代码。

        // compiles jrxml
        JasperCompileManager.compileReportToFile(reportName + ".jrxml");
        // fills compiled report with parameters and a connection
        JasperPrint print = JasperFillManager.fillReport(reportName + ".jasper", parameters, connection);

        // to view the report
        //JasperViewer.viewReport(print, false);

        // export repor to pdf
        JasperExportManager.exportReportToPdfFile(print, "fromXml.pdf");

When I view the report using JasperViewer , it works fine. 当我使用JasperViewer查看报告时,它工作正常。 But When I exporting the report into pdf format, it gives me the following exception. 但是,当我将报告导出为pdf格式时,出现以下异常。

Exception in thread "main" java.lang.NoClassDefFoundError: com/itextpdf/text/DocumentException

But I have put the iText jar into my libraries. 但是我已经将iText jar放入了我的库中。

在此处输入图片说明

But one thing, I had another version of iText jar before. 但是有一件事,我之前有另一个版本的iText jar。 It gave me the same exception. 它给了我同样的例外。 I thought that there may be some issues with the version of it.(I followed a tutorial, so I added the same jar as they had used in the tutorial replacing the new jar I had used). 我以为它的版本可能有问题(我遵循了一个教程,所以我添加了与教程中使用的相同的jar替换了我使用的新jar)。

but still the problem remains. 但问题仍然存在。 I thought this may be the issue now(the accepted answer of the question). 我认为可能是现在的问题(问题的公认答案)。 But I do not know how to fix it. 但是我不知道如何解决它。 I removed the entire library and added it again with iText jar which had been used by the tutorial. 我删除了整个库,并使用本教程使用的iText jar再次添加了它。 But I had no luck. 但是我没有运气。

Could you please help me to overcome this issue. 您能帮我解决这个问题吗? Thank you! 谢谢!

You need to upgrade your iText-2.1.7.jar file to latest version as earlier the package that was used by jar is com.lowagie... 您需要将iText-2.1.7.jar文件升级到最新版本,因为jar所使用的软件包较早是com.lowagie...

See the change list here which says it has changed the package name. 请参阅此处的更改列表其中说它已更改软件包名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError: com/itextpdf/text/DocumentException - java.lang.NoClassDefFoundError: com/itextpdf/text/DocumentException 如何在线程“ main”中修复异常java.lang.NoClassDefFoundError:com / itextpdf / text / DocumentException - How to fix Exception in thread “main” java.lang.NoClassDefFoundError: com/itextpdf/text/DocumentException java.lang.noClassDefFoundError:Java Applet上的com / itextpdf / text / element - java.lang.noClassDefFoundError: com/itextpdf/text/element on a Java Applet java.lang.NoClassDefFoundError:com / itextpdf / text / element - java.lang.NoClassDefFoundError : com/itextpdf/text/element 获取异常.NoClassDefFoundError:com / itextpdf / text / log / CounterFactory - getting exception .NoClassDefFoundError: com/itextpdf/text/log/CounterFactory 从servlet读取输入流时,“ com.itextpdf.text.exceptions.InvalidPdfException:未找到PDF标头签名” - 'com.itextpdf.text.exceptions.InvalidPdfException: PDF header signature not found' when reading the input stream from servlet 将Jasper报告导出为pdf时出错 - Error when exporting jasper reports to pdf com.itextpdf.text.exceptions.InvalidPdfException:未找到PDF标头签名 - com.itextpdf.text.exceptions.InvalidPdfException: PDF header signature not found java XMLWorkerHelper-NoSuchMethodError:com.itextpdf.text.pdf.PdfPTable.addCell - java XMLWorkerHelper - NoSuchMethodError: com.itextpdf.text.pdf.PdfPTable.addCell com.itextpdf.text.pdf.PdfPKCS7库不存在于Java IText中 - com.itextpdf.text.pdf.PdfPKCS7 library not present in java IText
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM