Jump to content
Changes to the Jaspersoft community edition download ×

Is there a way to invoke compiled .jasper in server?


mchisty

Recommended Posts

As from the official documentation (JasperReports-Server-REST-API-Reference.pdf), it was found that a sample report (e.g. CutomersReport) published in jasper server can be invoked by the following restful api,

http://somehost:8080/jasperserver/rest_v2/reports/reports/interactive/CustomersReport.pdf
or,
http://somehost:8080/jasperserver/rest_v2/reports/reports/interactive/CustomersReport.csv
or,
http://somehost:8080/jasperserver/rest_v2/reports/reports/interactive/CustomersReport.html
etc

Question is: is there any way to locate the compiled .jasper file in the report server? (E.G. something like http://somehost:8080/jasperserver/CustomersReport.jasper ???)

Thanks.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi M Chisty, why do you need access to the .jasper file on the server? It should be an internal object stored in a temp area of the app server once a report is executed, and not accessible to JRS users.

You could download the JRXML file via REST and then compile it locally.

Link to comment
Share on other sites

Hi Mate,

Thanks for your feedback.

As you mentioned "You could download the JRXML file via REST and then compile it locally. " ... . That's something I was actually looking for.

Now to answer your question: "why do you need access to the .jasper file on the server? ", I am providing a piece of code below which is currently working properly in our system. We are using iReport5.5 to design/compile reports. The reports (source/binary) are bundled with our EAR file (e.g. /mars-ejb/resources/META-INF/jasper-reports/reports/espl/esl_ej_final_assessment_notice.jrxml and /mars-ejb/resources/META-INF/jasper-reports/reports/espl/esl_ej_final_assessment_notice.jasper).

We have two types of reports:

  1. Type (1): SQL query embedded within reports
  2. Type (2): Java ArrayList is populated and filled in report

We have decided to migrate to TIBCO JasperSoft solutions (with JasperStudio and Jasperreports Server, as because iReport is now deprecated). For this, Type (1) is not a problem. But I do not know how to achieve Type (2) i.e. how do I pass the populated ArrayList objects in .jasper file.

Our current code is like this:

public static byte[] generateJasperPdfReport(String path, Map<String, Object> parameters, List<?> objects) throws Exception {    if (StringUtils.isBlank(path)) {        throw new Exception("Report generation path can't be empty");    }    if (null == parameters) {        parameters = new HashMap<>();    }    path = "/META-INF/jasper-reports" + path;    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);    byte[] bytes = null;    if (null != objects && !objects.isEmpty()) {        bytes = JasperRunManager.runReportToPdf(is, parameters, new JRBeanCollectionDataSource(objects));    } else {        bytes = JasperRunManager.runReportToPdf(is, parameters);    }    return bytes;}[/code]

    
When we want to generate a report (PDF byestream), we call our util class like this with passing the jasper file location, required parameters and ArrayList:

E.G.

List<PslPropertyDetailDTO> properties = ... // Some list of Java DTO objects hereMap<String, Object> parameters = .... // Some parameters provided...// Then invoke the util classbyte fileData[] = ReportUtil.generateJasperPdfReport("/reports/parkingSpaceLevy/psl_modify_property.jasper", parameters, list);[/code]

 

As you can see, if our report is deployed in the jasper server and our EAR/WAR file is deployed another server (JBoss/Tomcat etc), we cannot locate .jasper file path like this "/reports/parkingSpaceLevy/psl_modify_property.jasper".

In such a case, your suggestion about "download the JRXML file via REST and then compile it locally" might be one solution.

 

Question is: how/where can I locate the jrxml file? Is there any example?

Thanks.

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