I’ve already posted this issue yesterday on Jasper forum, but nobody answered yet. So maybe here I’ll have more success?!
I’m having an issue with my report when I have a subreport which contains another subreport:
When I declare my subreports I use the path: $P{SUBREPORT_DIR} + “my_report.jasper”
But for some reason, when I have a subreport which contains another subreport, the last one raises an error saying that it cannot find the path P:\developement_folder\iReports\my_report.jasper
Why does it take the default value? It looks like $P{SUBREPORT_DIR} works ok with a first layer of subreports but not with a second layer?
I could fairly easily use a workaround by sending the path as a parameter when I run the report and then forward it to my subreports, but it should work as it is now, shouldn’t it?
So you distribute/sell/license your actual Servoy solution for installation on third-party hardware and the install path is presumably different each time?
All my reports are at the same level in the same folder.
reportsDir\mainReport.jasper (contains subReport1)
reportsDir\subReport1.jasper (contains subReport2)
reportsDir\subReport2.jasper
If they could be placed in media they would be completely portable, so it might be worth trying to place them in media for the given solution, and then set your jasper reports directory property (server plugin property) to ‘media:///’. The jasper reports server property for the reports dir will be evaluated in the Servoy context so media may very well resolve.
I was researching this a bit further and came across the following description for Jasper’s REPORT_CLASS_LOADER built-in report parameter.
REPORT_CLASS_LOADER
Resources such as images, fonts, and subreports can be referenced using their relative classpath location. By default, JasperReports uses the current thread’s context class loader to locate the resource. If that fails, it then falls back to the class loader that loads the library’s classes themselves. To extend the resource-lookup mechanism and give greater flexibility to the library, you can pass a custom-made class loader implementation as the value for the REPORT_CLASS_LOADER fill-time parameter. This would allow applications to load resources from repository locations that are not normally part of the overall application classpath.
Another option might be
REPORT_URL_HANDLER_FACTORY
With this in mind, it might make sense to implement a custom class loader that can look for resources in media:// (as an example) or in some other default location that is known to servoy.
Try passing the parameter SUBREPORT_DIR explicitly to your sub report. Because my experience is that they aren’t automatically passed to your sub reports. So in your main reports call to sub report parameters add name ‘SUBREPORT_DIR’ with value $P{SUBREPORT_DIR}. I had the same kind of trouble with the REPORT_RESOURCE_BUNDLE and REPORT_LOCALE when using i18n key values in sub reports.