I like the ability of using foundsets in jasperreports (it adds a lot of potential for report reuse and centralization of logic).
I’m having issues though with foundsets and subreports in the smartclient launched specifically from the servoy application server.
I’m passing a main foundset to a main report. I am also passing an unrelated foundset as a parameter to the main report for use by the subreport (as described at http://www.mindfiresolutions.com/Adding … in-724.php).
This works wonderfully in the smartclient and webclient (the main report shows the data from the main foundset and the subreport shows data from the unrelated foundset).
Unfortunately when I launch the smartclient from the application server, the report isn’t displayed. Instead, when I launch the report, I get the error message:
ERROR - Debug - Throwable
net.sf.jasperreports.engine.JRException: Could not load object from location : /usr/local/servoy_5/application_server/reports/subreport1.jasper
at net.sf.jasperreports.engine.util.JRLoader.loadObjectFromLocation(JRLoader.java:255)
When I remove the subreport from the mainreport, then the error message isn’t thrown and main report is correctly shown (ofcourse without the subreport).
It looks like the use of an unrelated foundset (given as parameter to the main report) in a subreport needs some kind of class or jar-package that is available in the developer environment, but not in the application server environment.
Has anyone else experienced this issue (a specific report which works fine in the developer, but not on the application server)?
It just looks like it tries to access to subreport1.jasper (your sub-report) in /usr/local/servoy_5/application_server/reports/ but it’s not there or cannot be opened.
Have you checked if the file is there? To run a report which has a sub-report you need both files, the main report and its sub-report.
Foobrother is correct you need both files. However the subreport has to be the compiled file (ending in .jasper). So you have to compile the subreport then move or copy the .jasper file to the directory specified in the error message.
Also when specifying the subreport in the main report do not forget to specify the subreport with the .jasper extension and NOT the .jrxml extension.
Thanks for the replies.
The mainreport as well as the subreport files are indeed in the report directory. I can verify this, because it runs fine in the developer (smartclient & webclient).
The issue occurs only when the report+subreports is executed on the application server.
I’ve changed the mainreport and subreports to work with sql now intead (the queries are given as parameters that are evaluated with p!{query} ) and this works perfectly in both developer environment aswell as application server environment.
But this is ofcourse not a definite solution to the issue (working with unrelated foundsets that are given as parameters in subreports).
Maybe I should try the new ireport version released previous week.
I will try to post a sample report (with subreports and unrelated foundsets) later so I can concretely demonstrate the issue.
Quite overdue, but as promised: a sample report to demonstrate the issue.
I make use of the example database in the given samples.
I made two reports:
one main report based on the shippers table of the example database. It uses the shippers foundset.
one subreport based on the employee table of the example database. It uses the unrelated employee foundset (given by Servoy as parameter to the main report).
I made a solution with two forms:
one form shows all the data of the shippers table in a tableview
one form shows all the data of the the employee table in a tableview
Then I call the reports through a button with the statements described below.
The mainreport with subreport show fine in the developer.
But when using the report on the application server, an error is generated (see the posts above). When removing the subreport from the mainreport, everything works fine on the application server though (so the report path is correct).
Is anyone else able to reproduce this issue?
Statements used to call the reports:
//prepare parameters for report
var params = new java.util.HashMap();
params.put('foundsetParameter', forms.employees.foundset)
plugins.jasperPluginRMI.runReport(forms.shippers.foundset,'bugreport1.jrxml',null,'view', params );
With the recent release of JasperReport Plug-in, Now, you can directly add any fields, calculations(stored/un-stored), aggregations, global variables, related fields and many more, to your Jasper Report, as you are doing in Servoy itself. You don’t have write huge SQL Query for the same. Just pass your foundset to the report and access the fields, related fields from the JasperReport basing on the passed foundset. In this TIP, we will know how we can add a Sub-Report to the Jasper Report and pass a Servoy Foundset to the SubReport.
To add a Sub-Report to your JasperReport at design time with IReport (IReport is the popular Jasper Report Designer tool), you can drag the Sub-Report element from the Element pallet of IReport, to the JasperReport. This will generate the below XML for you.