Jump to content

Do subreports need to be pre-compiled into .jasper


ministrymason

Recommended Posts

I have a main report containing 5 sub reports it all works great in Ireport but If i delete all of the subreport .jasper  files so im left with the subreport.jrxml files. I get the following error when run in eclipse.

JRException=Could not load object from location : C:/jasperReports/subreport.jasper

Does this mean that the subreports all have to be pre compiled before i run the main report? As its saying it cannot find the .jasper?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hello,

               The ".jasper" files are similar to ".class" file. When run the application, jasper files are important, bcoz, the compiler needs the jasper files only not the jrxml. if u can run an application without jrxml but not .jasper. so compile the jrxml and put the jasper in the appropriate location and run it.

 

Bye

Link to comment
Share on other sites

  • 2 weeks later...

In case when you are creating report from Java code I would suggest to use code similar to listed below:

 

InputStream fullPathToSubReportAsInputStream = new ClassPathResource("SUBREPORT1.jrxml").getInputStream();

 

/* Compiling the report using prepated template. */

JasperReport subreport1 = JasperCompileManager.compileReport(fullPathToSubReportAsInputStream );

 

/* Setting sub report 1 as a parameter of main report. */

parameters.put("SUBREPORT1", subreport1);

 

Hope that will help.

 

Best regards,

Taras Matyashovsky

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