Jump to content
Changes to the Jaspersoft community edition download ×

problem uploading report with subreport using Jasperserver and iReport (both v4.5.0)


maartenstachanov.com

Recommended Posts

I create the report, and the subreport correct: if I press preview in the iReport it works correctly.

But when I upload it to the server using the server repository it fails: I don't get the dialog "replace this by that " (${dir} +subreport.jasper" with "repo:subreport.jrxml" instead I get an exception displaying: "Message: (Null)"

I even tried manually inserting the repo:subreport.jrxml in the main jrxml.

I've tried the following:

  1. create subreport
  2. create main report
  3. open repository
  4. go to folder
  5. "add new JasperReport"
  6. select the main report
  7. select database source on the repository that works (verified by using a simple report)
  8. uploading starts <note: here I would expect the dialog to replace the paths>
  9. "Message: (NULL)"
  10. refresh repository (Main.jrxml is there, but not the subreport)
  11. add the subreport.jrxml in the resources folder
  12. download Main.jrxml edit the jrxml variables to refer to: "repo:subreport.jrxml" and upload again
  13. run report: exception is displaying that it cannot find the resource "path/to/subreport.jasper".

I also tried to edit the mainreport.jrxml to have the right "repo:subreport.jrxml" and upload the subreport manually but that also fails.

Greets,

Maarten

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Several months ago I got some great suggestions on how to write the jrxml in such a way that it works in preview mode AND when it's deployed to JasperReports Server so you don't have to keep changing the code each time you change environments.  My notes may be out of date (I see that I added further notes to my original notes, etc.), but for what they're worth...

Source: djsiders on JasperForge.net 11/23/2010

Something I have found useful to have to keep from having to flip back and forth between the repository name and the local file path when working in iReports and the deployed server version of a report.

Create a Parameter IS_RUNNING_LOCAL - type Boolean - default value false - use for prompt

Create another Parameter SUB_REP_LOCATION - type String - do not use for prompt - set default to code below:

$P{IS_RUNNING_LOCAL}.booleanValue() ? "SubReportName.jasper" : "repo:SubRepReposName"  

Then set your SubReport Expression property to:  $P{SUB_REP_LOCATION}

Of course change the two report names to match your sub report names.  When deploying to the server do not use either of these params as input, just the boolean when running iReports.  When you run in iReports, answer true to the IS_RUNNING_LOCAL prompt.  This will cause iReports to use the local name/path.  When running on the server with no prompt, it will default to false and use the repository name for the subreport.

If you are doing a lot of dev work, you can temporarily change the default value to true so you can use the default of the prompt.  An added benefit is that iReport will then find and compile the sub-report (at least in later iReport versions) as well.

(Carl: I have more luck ending the repo: version of the name with the .jrxml extension.  Also, when I run a preview of the main report in iReport, I get warnings during the compilation that the compiler is ‘Unable to locate the subreport with expression: “$P{SUB_REP_LOCATION}”’  Not to worry.  That’s just because that parameter is filled in at run-time.  As soon as you get the prompt and answer “true”, it should run fine.  If you have multiple subreports, just create multiple parameters with different extentions: $P{SUB_REP_LOCATION_ASSETS}, $P{SUB_REP_LOCATION_LIABILITIES}, etc.)

(Carl: rumor has it that the default behavior when deploying a main report to JasperServer changed after V3.7.1.  One person recommends deploying Main report first, skip automatic procedure for subreports, then deploy subreports in resource folder as separate .jrxml files (or you can deploy them as their own report units for stand-alone capability).  Then in the main report, set the subreport expression to the FULL pathname (apparently regardless of whether or not you’ve deployed as a resource), without an extension.  It should be something like “repo:/Reports/MainReportName/subreportName”.  To find actual full pathname, right click after the subreport in the repository navigator and select “Properties”.)

--Carl

P.S.: Thanks for posting the solution you found as well...sometimes people who find the answers to their own questions don't post them, and inquiring minds want to know! :)



Post Edited by cbarlow3 at 02/02/2012 17:28
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

The tool JDeploy! on http://sourceforge.net/projects/jaspertools/?source=directory

allows to deal with reports and subreports deployment on diferents environments (development, pre production, production). It dont touch the datasources when deploying a report, so the systems department can define it. It also defines a estandarized way to package the reports and subreports of a project on a zip file. And includes other utils to list reports, create datasources,... It does not requires editing the jrxml file.

I hope to helped you.

bye.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...