Jump to content
We've recently updated our Privacy Statement, available here ×

min_3

Members
  • Posts

    11
  • Joined

  • Last visited

Recent Profile Visitors

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

min_3's Achievements

Apprentice

Apprentice (3/14)

  • Dedicated Rare
  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare

Recent Badges

0

Reputation

  1. I have a jasper report that uses a JSON data adapter to retrieve data from a rest api. The url is being set dynamically in the report using parameters and the user is prompted to supply a value for paramId: <parameter name="paramId" class="java.lang.String" evaluationTime="Early"> <defaultValueExpression><![CDATA["1"]]></defaultValueExpression></parameter> <parameter name="url" class="java.lang.String" isForPrompting="false" evaluationTime="Early"> <property name="net.sf.jasperreports.http.data.url"/> <defaultValueExpression><![CDATA["http://aServiceEndpointUrl/" + $P{paramId}]]></defaultValueExpression></parameter> This all works well if the paramId supplied in the default value expression results in a valid json response from the endpoint call. However they way our endpoints are written, if the supplied paramId does not find any data it returns a 404 response. In this case I get a "There was an error on the server. Try again or contact site administrators. (Error UID: 5d62fb9a-204c-447e-8634-6f703699926d)" error on the report even before the input parameters screen is displayed and I don't even get a chance to supply a valid value for paramId. This creates a dependency on data supplied in the default value expression always being valid. Is the solution to ensure that the endpoint returns an empty string rather than a 404 error or is there a better way to implement this? I notice that based on the following thread the data adapter gets run twice. https://community.jaspersoft.com/questions/1111291/web-service-using-json-data-adapter-passing-http-parameters-url-body-through
  2. I am using a custom font in my jasper report . The report is available as HTML format and PDF. In order for the font to be available to the pdf exporter, is the only way to add the font jar to the report as a resource? Does that mean I need to do this for each individual report as per instructions on https://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-user-guide/v640/working-font-extensions ?
  3. Is there a way to handle the 404 error in the scenario where a report obtains data from rest api using the JSON file adapter and no data is returned? Setting the 'When No Data Type' at the report level does not seem to stop the report from erroring with a 404 error.
  4. Am I able to use a variable or parameter in a JSONQL filter expression in the main dataset of a report? Eg. with the following basic structure, I want to only retrive objects with a completionYear of the current year [ { id: 1, organisationId: "a1", startYear: 2019, completionYear: 2019, compressed: false, approved: true }, { id: 2, organisationId: "a2", startYear: 2019, completionYear: 2021, compressed: false, approved: true }, { id: 3, organisationId: "a3", startYear: 2019, completionYear: 2022, compressed: false, approved: true } ] How would I specify something like this: <queryString language="jsonql"> <![CDATA[*(completionYear >= $V{currentYear})]]> </queryString> without getting an "unexpected token: $V" error?
  5. Thanks for your help so far @narcism. I've set the net.sf.jasperreport.data.adapter to my xml file and all parameters involved in the URL creation to "Early" but am still getting the NPE when previewing the report in jasperstudio. I'm running version 6.6.0 community edition. The report previews successfully when I have not set "net.sf.jasperreport.data.adapter" to my xml file, but use "com.jaspersoft.studio.data.defaultdataadapter" to access the same xml file in my workspace.
  6. I am getting a NullPointerException when trying to preview the report after setting the "net.sf.jasperreport.data.adapter" value to my xml file. Could it be because I have blanked out the url in the data adapter and am using the "net.sf.jasperreports.http.data.url" property to dynamically set the url? net.sf.jasperreports.engine.JRException: java.lang.NullPointerException at com.jaspersoft.studio.editor.preview.view.control.ReportController.fillReport(ReportController.java:536) at com.jaspersoft.studio.editor.preview.view.control.ReportController.access$17(ReportController.java:511) at com.jaspersoft.studio.editor.preview.view.control.ReportController$1.run(ReportController.java:429) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) Caused by: java.lang.NullPointerException at net.sf.jasperreports.eclipse.util.HttpUtils$1.determineRoute(HttpUtils.java:57) at org.apache.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:124) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:183) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107) at net.sf.jasperreports.data.http.HttpDataConnection.getInputStream(HttpDataConnection.java:67) at net.sf.jasperreports.data.DataFileStream.(DataFileStream.java:47) at net.sf.jasperreports.data.DataFileUtils.getDataStream(DataFileUtils.java:79) at net.sf.jasperreports.data.json.JsonDataAdapterService.contributeParameters(JsonDataAdapterService.java:75) at net.sf.jasperreports.engine.fill.JRFillDataset.contributeParameters(JRFillDataset.java:1153) at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:665) at net.sf.jasperreports.components.list.FillDatasetRun.start(FillDatasetRun.java:164) at net.sf.jasperreports.components.list.VerticalFillList.prepare(VerticalFillList.java:102) at net.sf.jasperreports.engine.fill.JRFillComponentElement.prepare(JRFillComponentElement.java:152) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:325) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:256) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:110) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:615) at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:135) at java.lang.Thread.run(Thread.java:748) Also the published .xml file was renamed to .xml__6378735146977274512. Is this what it should do? Should the report also be pointing to this xml when I look at the Data Source for this report on the server?
  7. Great, I have so far been able to successfully get that to work. But when I deploy this report to the report server, how do I set up the datasource?
  8. Thanks for the guidance @narcism - I have tried and got that to work. However, with the URL that I specifiy in the JSON data adapter, can that be made dynamic? e.g. https://jsonplaceholder.typicode.com/todos/{id}
  9. No but am currently trialling the latest community version that is available for download. Do the different versions provide different support for api access?
  10. I have used the Web Service Data Adapter to connect to a REST API as a datasource for my report. The output is in JSON format. My question is what syntax do I use to be able to traverse through the nodes in the JSON file? Am I able to skip a node using a JSONPATH expression? I've followed the tutorials on https://community.jaspersoft.com/project/web-service-data-source and have successfully managed to get the api to run, but not able to read the input fields as they are not returned in an array. I am trying to read the tgaCode (highlighted below):
×
×
  • Create New...