Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JasperReports: filling a report throws an exception "Class not found when loading object from file"

I'm using the latest JDK and JasperReports. The reports are designed and compiled with iReport (4.02). Compiled reports are deployed to Eclipse project which is integrated with a Tomcat installation on Windows.

The problem is that calling JasperFillManager.fillReport(String sourceFileName, Map params, Connection connection), with correct parameters in place, will cause an exception with a message "net.sf.jasperreports.engine.JRException: Class not found when loading object from file".

I've debugged the code and all parameters have valid values. Also the reports work fine when previewed in iReport. I've copied all jar files from the Jasper project lib dir to my Web App Libraries.

The code is divided in multiple places in the actual code but the significant parts are below:

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;
like image 825
jasper newbie Avatar asked Oct 16 '25 14:10

jasper newbie


2 Answers

Problem solved.

The issue was caused by iReport Designer. I had defined some color formatting by selecting from available predefined color list instead of the the color wheel. This cause the reports to use variables from NetBeans jars instead of using color values.

like image 74
jasper newbie Avatar answered Oct 18 '25 05:10

jasper newbie


I used jasperreports-6.17.0.jar and the issue is solved. Old versions created issue.

like image 42
buket genç Avatar answered Oct 18 '25 05:10

buket genç



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!