John Little
John Little

Reputation: 12343

JasperReports Server cant find sub reports

I have a main report which calls a sub report which calls another sub report.
I have all 3 in a dir called dash2 in report studio.

When I use report studios deployment to *JasperReports Server * on the main report, it also seems to deploy the first sub report (but not the sub sub report). Well, If I right click on the report and select edit, then Controls and Resources, it lists the sub report.

If i manually deploy all 3 reports one by one, I see all three in the report folder in Jaspersoft Studio. However, if I try to run the main report, I get:

Error filling report
net.sf.jasperreports.engine.JRException: Resource not found at : dash2/dash-kpi.jasper

So its looking for the sub report in dash2. So I created a dir called dash2 under the main report folder, and copied the sub reports into it. Same error. So I manually reproduced the same structure as in report studio -no joy. It can never find the sub report.

In the main report, it has this entry:

<subreportExpression><![CDATA["dash2/dash-kpi.jasper"]]></subreportExpression>

Any ideas how to fix?

It works fine in report studio.

Edit: tried removing the "dash2/" from in front of the resource name. didn't help.

Edit2: tried chaing all occurunces of dash2/xxx.jasper to repo:xxx.jrxml. This breaks jasper studio in that:

  1. the reports no longer work in studio
  2. when you upload the main report, it no longer recognises the dependent sub reports and doesn't upload them.

I tried manually deploying all reports, but there is no way to link a main report with an existing sub report in jasper server. The only option they offer is to edit the main report, and manually upload the jrxml files as resources. I tried this, but didn't help, still cant find them:

 Repository file resource /reports/dashboard_files/dash_kpi.jrmxl could not be loaded

Interestingly, its using a dir called dashboard_files which doesnt exist. There is no reference to this dir in any of the reports jrxml files.

Upvotes: 1

Views: 6195

Answers (2)

user4371138
user4371138

Reputation: 1

I have overcame this problem by simply NOT using the onServer parameter. Should you put just the file name, the Studio can grab this file and deploy it automatically. Strangely enough, this works on the server as well.

Upvotes: 0

John Little
John Little

Reputation: 12343

After much pain, I found a solution. It seems that jasper studio is not really good with nested sub reports. Here is a solution at a high level, which applies to server 5.6 and Studio 5.6 at least:

  1. Start off with the reports with sub reports defined as "xxx.jasper" in studio.
  2. Deploy the main report to jasper server. It will ask you if you want to deploy the sub reports (but not their sub reports). However, it does not do it right, and we have to fix it.
  3. Now connect to the server from studio (aka repository explorer)
  4. Your report will be under SErvers->your server->Reports->reportname->Main.jrxml. Right click on it and select properties. Select Resource Editor Tab.
  5. copy the Parent Folder path. e.g. /reports/myreport_files
  6. Now go back to studio. Edit every place in all your reports and sub reports where you have "xxx.jasper" and replace them with "repo:/reports/myreport_files/xxx.jrxml"
  7. save everything
  8. Deploy the main report again.
  9. in Jasper Server, find the report, right click on it and select EDIT
  10. Click on "Controls and Resources".
  11. Delete all the resources
  12. Now Add back each sub report by uploading by hand each jrxml file. Make sure you give it the same name and ID ans the file, e.g. my_sub_report.jrxml
  13. pray it works.

NOTE 1: if you have any "-" in your subreport names, they will be converted to "", and it wont find them. rename all your subreports with "-" to use "" insead, remove and re-deploy.

NOTE 2: Now your reports wont work in studio. Nice one Jasper. You can try using parameters, e.g:

$P{IsOnServer} ? "repo:/reports/myreport_files/my_sub.jrxml" : "my_su.jasper"

And create the parameters defaulting to true, but I could not get this to work.

Main credit to these guys:

Upvotes: 2

Related Questions