我正在使用最新的 JDK 和 JasperReports。这些报告是使用 iReport (4.02) 设计和编译的。编译后的报告被部署到 Eclipse 项目,该项目与 Windows 上的 Tomcat 安装集成。
问题是使用正确的参数调用 JasperFillManager.fillReport(String sourceFileName, Map params, Connection connection) 会导致异常并显示消息“net.sf.jasperreports.engine.JRException: Class not found when从文件加载对象”。
我已经调试了代码并且所有参数都具有有效值。在 iReport 中预览时,报告也能正常工作。我已将 Jasper 项目库目录中的所有 jar 文件复制到我的 Web 应用程序库中。
代码在实际代码中分为多处,但重要的部分如下:
JasperPrint print = JasperFillManager.fillReport(templatePath, params, conn);
byte[] output = null;
try {
output = JasperExportManager.exportReportToPdf(print);
} catch (JRException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return output;
最佳答案
问题解决了。
此问题是由 iReport Designer 引起的。我通过从可用的预定义颜色列表而不是色轮中选择来定义一些颜色格式。这会导致报告使用来自 NetBeans jar 的变量,而不是使用颜色值。
关于java - 碧 Jade 报告 : filling a report throws an exception "Class not found when loading object from file",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6649886/