Using subreports in Jasper iReport
When trying to create a subreport in Jasper, I kept receiving the following error:
net.sf.jasperreports.engine.JRException: Could not load object from location
every time I tried to generate a sample PDF file. The subreport has its own SQL statement and needs to select data based on an id number passed as a parameter from the main report, so for the longest time I thought I was passing the parameter wrong.
Turns out that the real problem was in order to make a subreport work it has to be compiled. I had it compiled, but the compiled version of the resport (ending in .jasper) was being saved in a different folder. I didn’t know it was .jasper so I tried to specify every possible path to the .jrxml file which did not work.
So for anyone experiencing this problem, here’s what to do:
- Compile the subreport.
- Find the compiled .jasper file.
- Make sure your main report is referencing this .jasper file and nothing else.

which folder is jasper file available, i ran a search but was unable to find it
If you can’t find the .jasper file you probably didn’t compile the report yet. Hit the compile button in iReport – it looks like a gear. Also check the messages and make sure the report doesn’t have an error that prevents compilation.