tjasperreport tutorial

Integrating Jasper Report in Talend Open Studio(tJasperOutput)

Use the tJasperOutput component to run a Jasper Report from Talend Open Studio.  This component allows a report to be produced after a data flow is executed.

tJasperOutput-1

To execute a Jasper Report from Talend Open Studio, add a tJasperOutput component to the canvas.  Use a flow to invoke the component.  This below example uses a query to generate a report.

Make sure that the query used in the flow is the same used for Jasper Report.

tJasperOutput-2

Configure the tJasperOutput by specifying the JRXML file, the output file name, and the report type (PDF, HTML, etc.).  Also, make sure that there is a valid iReport command.  Add the file path to the ireport executable.  Test this with the "Launch" button.

This report uses a complex example to demonstrate the functionality and at the end we have dealt with few error that might occur due to iReport version used.

Below Example has the title section and detail section to display the query result coming from the source.

And the result is a PDF which is stored in the in the output folder marked by Destination path.

When starting with tJasperOutput, try using a simple Jasper Report based on a string constant. This post above mentioned example illustrates the integration of Jasper Report with Talend ETL job and can minimize the effort to schedule a Jasper Report with the data load.

 

Troubleshooting:

Issue1 - Invalid content was found starting with element 'paragraph'. No child element is expected at this point.

Solution:

 Open the ireport

 Go to the xml view

 Ctrl+F

 Find also all xml tags with the word "paragraph" and delete each tag.

 Save the report in xml view only

Issue2 - org.apache.commons.digester.Digester error

SEVERE: Parse Error at line 2 column 459: <Line 2, Column 459>: XML-24535: (Error) Attribute 'uuid' not expected.

org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 459; <Line 2, Column 459>: XML-24535: (Error) Attribute 'uuid' not expected.

Solution:

To resolve this issue  report needs to be saved in a previous version of ireports such as 4.5 where the uuid's are not present in the report. After the recent upgrades with jasper with the uuid, the jasper components are not as updated.The uuid's cause a number of issues with other applications not just talend components.

Issue3 - Cannot cast from Date to String value = (java.lang.String)(new java.util.Date()); //$JR_EXPR_ID=10$

Solution: 

If you want to hold the date as a java.util.Date then you must add the class attribute to the testFieldExpression.

This Here convert "><textFieldExpression> to <textFieldExpression class="java.util.Date">

Likewise do it for other non string field expressions as well and save the report in xml format only. If we try to go back to designer or preview mode the above field settings might get disturbed.