Jump to content
JasperReports Library 7.0 is now available ×

mchisty

Members
  • Posts

    13
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

mchisty's Achievements

Apprentice

Apprentice (3/14)

  • First Post Rare
  • Collaborator Rare
  • Conversation Starter Rare
  • Week One Done
  • One Month Later

Recent Badges

0

Reputation

  1. The video is nice. Also some detailed steps are provided. However, this may not be enough as JasperSoft Studio is highly buggy tool (not as robust as the older tool iReport); therefore the tutorial still may not work sometimes. E.G. Step 1: Once jar is created, we may need to add the jars under the "..apache-tomcatwebappsjasperserver-proWEB-INFlib" directory. Step 2: If scriplet value shows in JasperStudio preview but the report output is not shown in JasperServer, this means there is a bug in 'DETAIL' band. I.E. if you place you scriptler inside 'Detail' band and preview it within Jaspersoft Studio, it will work just fine. Then publish it in Jasper Server and try to view the report, it will come as empty. This is bug in latest versions of Jaspersoft studio or, Jasper server (not sure which one, but all the TIBCO tools are buggy enough and not well documented. We need to find out resolution through lots of trial and error basis. TIBCO support team is not responsive at all) To solve this, place the scriptler in any other band e.g. in the 'Summary' band, then preview it and it will work; then publish and view it in Jasperserver, this will also work.
  2. In this article, we will see how we can create a report with JSON input parameter and call it from a SpringBoot application using a REST API call. Most of the examples available online only shows when the jasper template (jrxml/jasper file) is placed within the application (i.e. SpringBoot or any other java application). But in a real microservices world, the report MUST NOT be embedded within the application; rather it should be deployed in report repository/server and accesible via API call. The following steps will briefly describe what we are trying to achieve: (Note: this wiki page is still under construction. This will be finished within the next 3/4 days once all the screenshots and samples are completed. This will NOT be a fully completed application but it will show examples which will be sufficient enough to help those who have prior knowledge on SpringBoot and some ideas on Jasper report or iReport) Step 1. Create a simple report in JasperStudio. The input parameter should be JSON text (a JSON String or JSON array) Step 2. Deploy/publish the report in Jasper Server Step 3. Test: access the report in Jasper server by passing necessary parameters and view the generated PDF Step 4. Test: access the report from Postman using a REST Api call with necessary parameters and view the generated PDF Step 5. Create a RestController class in SpringBoot application (e.g. MyController.java) Step 6: Create a FeignClient in SpringBoot application (e.g. MyJasperFeignClient.java) Step 7: Create other necessary classes/configuration to enable MyController (Step 5) to communicate with MyJasperFeignClient (Step 6) Step 8. Deploy SpringBoot application and test the report from Postman using a REST Api call with necessary parameters and view the generated PDF Step 1. Create a simple report in JasperStudio. The input parameter should be JSON text (a JSON String or JSON array)
  3. Hi, We are using SpringBoot for microservices solution. For reporting solution, we are in the process of migrating to JasperSoft latest version 8.1.x. We have a requirement as follows: Step 1: A SpringBoot class/API (@RestController) should invoke a Jasper report API published in JasperServer by passing a list of DTO objects e.g. as a request body. The report URL may look like this http://localhost:8080/jasperserver/rest_v2/reports/LT/stimulus.pdf Step 2: The expectation is that the PDF report should be generated based on the json data provided in request body Questions: Q1. Can you provide any example using which we can achieve the above? Please note: Most of the examples online are not very useful; they are very basic and they mostly show about placing the .jrxml or .jasper file within the spring boot application. (screenshot attached which is a bad example; very old style approach). And this is not what we are looking for. The jrxml/jasper template should only deployed in the jasper server and we want to produce the report by making a REST API call from Java/Spring and passing json data in request body or JRBeanCollection etc. Q2. Is there any sample where we can test from Postman API by calling a jasper report by passing json input in request body? Your feedback would be appreciable. With Thanks.
  4. Just comment (or remove) those lines in applicationContext-remote-services.xml You will find this file under you tomcat directory (e.g. under "..apache-tomcat-9.0.70webappsjasperserverWEB-INFapplicationContext-remote-services.xml" if you have already installed jasper server) <util:set id="customDataSourcesToHide"> <value>remoteXmlDataSource2</value> <value>remoteXmlDataSource</value> <value>mongoDBQueryDataSource2</value> <value>mongoDBQueryDataSource</value> <!-- value>jsonDataSource2</value --> <!-- value>jsonDataSource</value --> <!-- value>jsonQLDataSource</value --> <value>jdbcQueryDataSource2</value> <value>jdbcQueryDataSource</value> <!--<value>xlsDataSource</value> --> <!--<value>xlsxDataSource</value> --> <value>textDataSource</value> <!-- value>JsonSeriesDataSource</value --> <value>xmlaQueryDataSource</value> <value>cassandraQueryDataSource</value> <value>HiveDataSource</value> </util:set>
  5. You should comment those, not uncomment. Like this: <util:set id="customDataSourcesToHide"> <value>remoteXmlDataSource2</value> <value>remoteXmlDataSource</value> <value>mongoDBQueryDataSource2</value> <value>mongoDBQueryDataSource</value> <!-- value>jsonDataSource2</value --> <!-- value>jsonDataSource</value --> <!-- value>jsonQLDataSource</value --> <value>jdbcQueryDataSource2</value> <value>jdbcQueryDataSource</value> <!--<value>xlsDataSource</value> --> <!--<value>xlsxDataSource</value> --> <value>textDataSource</value> <!-- value>JsonSeriesDataSource</value --> <value>xmlaQueryDataSource</value> <value>cassandraQueryDataSource</value> <value>HiveDataSource</value> </util:set>
  6. 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: Type (1): SQL query embedded within reportsType (2): Java ArrayList is populated and filled in reportWe 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.
  7. I like to add a bit more: The example provided here is applicable only if the report is in the same workstation with java appcation (the jasper report file .jrxml/.jasper is bundled with the web application, deployed in the same web/app server). But what if the report is depoyed in a remote jasper report server and not in the same server with the bundled web app? How do you pass the ArrayList of beans to the jasper file in such a case?
  8. Fine but there is one important point missing here: The example provided here is applicable only if the report is in the same workstation with java appcation (the jasper report file .jrxml/.jasper is bundled with the web application, deployed in the same web/app server). But what if the report is depoyed in a remote jasper report server and not in the same server with the bundled web app? How do you pass the ArrayList of beans to the jasper file in such a case? Thanks.
  9. 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.
  10. Hi, I saw method solutions like this (a sample provided below. Ref URL: https://www.programcreek.com/java-api-examples/index.php?api=net.sf.jasperreports.engine.JasperFillManager): try { Map<String, Object> params = new HashMap<String, Object>(1); params.put("upit", query); JasperPrint jp = JasperFillManager.fillReport(SearchReport.class.getResource( "/com/gint/app/bisis4/client/circ/jaspers/searchuser.jasper").openStream(), params, new JRTableModelDataSource(table)); return jp; } catch (Exception e) { log.error(e); return null; }[/code] However, there is not a single solution that says how to fill the report with JavaBean collection/ArrayList if the jasper report file is already deployed on the report server and NOT in the local workstation. Just observe the compiled file (searchuser.jasper) location here: "/com/gint/app/bisis4/client/circ/jaspers/searchuser.jasper" which resides in the local host. But a report published in a report server might be somewhere like: http://someJasperHost:8080/XYZ/searchuser.jasper, isn't it? Now-a-days, we do not put the .jasper files as bundled with local war/ear file; rather the reports (jrxml and jasper) are meant to be compiled/published on the report server. However, if we have an ArrayList of Java objects (beans/POJOS etc) and we want to fill the .jasper file (which is already published in the report server), how can we acheive that? Or, in other words, What is the best way to supply the ArrayList of Javabeans to a jasper report located in a jasper server and fill/populate it? Is there actually any solution/sample code for this? Thanks.
  11. I have a similar problem like yours. Could you please post your code fragment here? Really like to know how you solved it. Thanks.
×
×
  • Create New...