Jump to content

location of subreport ?


garyng

Recommended Posts

Hi,

 

I saw this as yet another FAQ in the forum yet there is again no definitive answer.

 

Using the xmldatasource example, I tried to run the CustomerReport on a tomcat server and get the following exception :

 

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRException: Could not load object from location : OrdersReport.jasper

 

The is of course the case as given the name, it is expected to load from "current directory" where on tomcat, it is tomcat's root.

 

Does this mean that every report that use subreport should be designed in a way that it takes a report parameter(like SUBREPORT_DIR as in iReport, like $P{SUBREPORT_DIR}/subreport.jasper) when specifing subreport ?

Link to comment
Share on other sites

  • 7 months later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I solved this by passing a hashmap parameter

parameters.put("SUBREPORT_DIR", "actual path to the subreport.jasper file location" );

should also end with a '', don't forget escape characters '' if you are hard-coding the path rather than use a file.getAbosolutePath() or something..

 

You have to mention in the subReport.jasper location correctly. First check by opening in i-report the subReport.jrxml report properties to see if the name matches with the correct name, for example, "childReport" given in the parentReport.jrxml's subReport location/expression as $P{SUBREPORT_DIR} + "childReport.jasper"

 

Make sure that the child is compiled to a .jasper before running your parent. If you don't know how to do that let me know!!!

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...