java NoClassDefFoundError: com/itextpdf/text/DocumentException 将 jasper 导出为 pdf 时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28394833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NoClassDefFoundError: com/itextpdf/text/DocumentException when exporting jasper to pdf
提问by vigamage
I created a jasper
report and now I need to export that report to pdf
format. This is my code for that.
我创建了一个jasper
报告,现在我需要将该报告导出为pdf
格式。这是我的代码。
// 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. But When I exporting the report into pdf
format, it gives me the following exception.
当我使用 来查看报告时JasperViewer
,它工作正常。但是当我将报告导出为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. 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).
但有一件事,我之前有另一个版本的iText
jar。它给了我同样的例外。我认为它的版本可能存在一些问题。(我遵循了教程,因此我添加了与教程中使用的相同的 jar,替换了我使用的新 jar)。
but still the problem remains. I thought thismay 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. But I had no luck.
但问题仍然存在。我认为这可能是现在的问题(问题的公认答案)。但我不知道如何解决它。我删除了整个库,并iText
使用教程中使用过的 jar再次添加了它。但我没有运气。
Could you please help me to overcome this issue. Thank you!
你能帮我解决这个问题吗?谢谢!