This blog will teach how to create Jasper Reports using iReport, the data source to be used is XML and then publish it on Jasper servcer
- Run iReport; it will open showing a Welcome Window, as shown in the following screenshot:
2. DataBase (DataSource ) Connection :
a.) Click On Datasource button
b) Click On new button
C) Select XML datasource
d) A new window named XML file datasource will open, as in the following
e) Enter AddressBook (you can give the name of your choice also) as the name for your new connection for the XML datasource in the text box beside the Name text field & Click the Browse button to browse to the addressbook.xml file located in the E:/ in my system. Select the Use the report XPath expression when filling the report option in the XML file datasource window,
f) Now click on “TEST” for testing the connection
3. Creating The Report : Open a new report and then go to “query browser”,choose the query language from drop down list as “xpath.” The text area below the Query language drop-down list will split into two parts. The left part shows the actual XPath expression, whereas the right part shows XML nodes
4. In the XML nodes right click on the name child of the person node,select “add node as field”,similarly for phone child of person node also.
5. Double-click on the Fields node in the Report Inspector window on the left of your report. The Fields node will expand to show the fields name, phone.
Drag-and-drop the name and phone field from the Fields node into the Detail section of your report.
6. Switch to the Preview tab and you will see your report The result should be similar to the below
7. Publishing the report to the jasper server
a) Creating data adapter :
a.) Creating Data Adapter : To use flat files as a datasource (like XML files) you need to use DataAdapters in Jasperserver instead of regular datasources. We can create them manually in the server (it’s just an XML file). Data Adapter is a way to define a source for Jasper Reports using a configuration file,(act as the bridge between data source and jasper reports while publishing the jasper report on Jasper Server).
<filename>repo:/reports/interactive/xmlData</filename> – > here xmlData is the name of the xml file(addressbook.xml) which we have to add again to the Jasper Server.(I have added this file in this location “repo:/reports/interactive/”.
b) We need to add XML datasource to server also
c) Adding xmlAdapter To The Properties attribute of Report.
Property Name : net.sf.jasperreports.data.adapter
Property Value : repo:/reports/interactive/xmlAdapter
Note: By default xpath or xpath2 language will not come in jasper server,for this you need to do three things…
- Copy jasperreports-extensions-3.5.3.jar from /ireport/modules/ext to JasperReports Server/jasperserver-pro/WEB-INF/lib/jasperreports-extensions-3.5.3.jar
- Add the following line to /jasperserver-pro/WEB-INF/classes/jasperreports.properties
- Restart Tomcat
Best Open Source Business Intelligence Software Helical Insight is Here