This tutorial covers step by step instruction on running Jasper Reports with Hadoop using Jaspersoft Studio easy and simple to use environment . Also, publishing the created sample report with Jasperserver that is connected to Jaspersoft Studio .

1. Prerequisites

a) BigSQL Tutorial is required to be followed till Step 3 http://www.bigsql.org/se/tutorial.jsp

Step 1 : Creating example.customer_history in HIVE and loading values.
Step 2 : Creating example.customer_history as foreign table in Postgres
Step 3 : Verifying example.customer_history

2. Things required to be downloaded

a) Download Jaspersoft Studio for your OS version from http://community.jaspersoft.com/project/jaspersoft-studio/releases

  • Select your OS version from Link column

  • After downloading completes , install the Studio

b) Download JasperReports Server from http://community.jaspersoft.com/project/jasperreports-server/releases for your OS version

c) Download JDBC file from http://jdbc.postgresql.org/download/postgresql-9.2-1003.jdbc4.jar

3. Simple Data Adaptor configuration

a) Verify if BIGSQL is running

$ ./bigsql status
#################################################
# BIGSQL:- your BIGSQL version
# TIME: current time
# HOST: your hostname
# JAVA: path to your JAVA_HOME
# OS: your OS
#################################################

## Checking critical ports ################
Postgres port 5432 is busy.
ZooKeeper port 2181 is busy.
HDFS port 50070 is busy.
HBase port 60010 is busy.
Hive port 9083 is busy.
Tomcat port 8080 is busy.

b) Run the installed Jaspersoft Studio instance

1) For DataAdapter , click Under Repositor Tab → Right click on Data Adaptors → Create New Data Adaptor → Next → Database JDBC Connection → Next

2) Database Location

    • Enter Name “BigSQL”
    • JDBC Driver : org.postgresql.Driver
    • JDBC Url : jdbc:postgresql://localhost:5432/postgres
    • Username : postgres
    • Password : password

3) Driver Classpath

    • Click on Add Button → Select Driver Path → Click Open

c) Click Finish Button to add the Data Adaptor

4. Easy Report Creation method

a) Create a new Project

  • File → New → Project → JasperReports Project .

b) Create New Jasper Reports

  • File → New → Jasper Report → Blank A4 → Enter Name: bigsql.jrxml → Finish.

c) Select created report and open “source” view .

  • Select all and Delete selected.

d) Hadoop JasperTest Report

“copy the below report in xml and below paste it in the ‘source’ tab of the created report”

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version last-->
<jasperReportxmlns="http://jasperreports.sourceforge.net/jasperreports"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"name="BigSQL"language="groovy"pageWidth="595"pageHeight="842"columnWidth="535"leftMargin="20"rightMargin="20"topMargin="20"bottomMargin="20"uuid="73c28c9e-7a45-457e-bb9c-d3b4a665aec8">
<propertyname="com.jaspersoft.studio.data.defaultdataadapter"value="BigSQL"/>
<stylename="Title"fontName="Times New Roman"fontSize="50"isBold="true"pdfFontName="Times-Bold"/>
<stylename="SubTitle"forecolor="#736343"fontName="Arial"fontSize="18"/>
<stylename="Column header"forecolor="#666666"fontName="Arial"fontSize="12"isBold="true"/>
<stylename="Detail"fontName="Arial"fontSize="12"/>
<stylename="Row"mode="Transparent">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<stylebackcolor="#E6DAC3"/>
</conditionalStyle>
</style>
<queryString>
<![CDATA[Select * from example.customer_history;]]>
</queryString>
<fieldname="hist_id"class="java.lang.Integer"/>
<fieldname="h_date"class="java.sql.Timestamp"/>
<fieldname="h_amount"class="java.math.BigDecimal"/>
<fieldname="h_data"class="java.lang.String"/>
<background>
<bandsplitType="Stretch"/>
</background>
<title>
<bandheight="136"splitType="Stretch">
<staticText>
<reportElementuuid="3cbe62a2-fc4f-4470-8a41-04ba5a76f4ff"style="Title"x="170"y="40"width="263"height="62"/>
<textElementverticalAlignment="Middle">
<fontpdfFontName="Times-Roman"/>
</textElement>
<text><![CDATA[BigSQL Report]]></text>
</staticText>
<staticText>
<reportElementuuid="9c023796-93e4-4fbf-a609-9537018b189c"style="SubTitle"x="350"y="50"width="196"height="22"/>
<textElement>
<fontfontName="Times New Roman"pdfFontName="Times-Roman"/>
</textElement>
<text><![CDATA[with Jasper Reports]]></text>
</staticText>
<image>
<reportElementuuid="805e8dcf-c46e-49df-9647-4f14646c972d"x="-1"y="0"width="161"height="110"/>
<imageExpression><![CDATA["/Users/alisaggu/Desktop/logo10.png"]]></imageExpression>
</image>
</band>
</title>
<pageHeader>
<bandsplitType="Stretch"/>
</pageHeader>
<columnHeader>
<bandheight="16"splitType="Stretch">
<line>
<reportElementuuid="26e9c0f5-5aea-4bd6-848c-8f9820d2cb6c"positionType="FixRelativeToBottom"x="0"y="15"width="555"height="1"/>
<graphicElement>
<penlineWidth="0.5"lineColor="#999999"/>
</graphicElement>
</line>
<staticText>
<reportElementuuid="ad2d59e2-f15f-4475-9fc4-8068d571e552"style="Column header"x="0"y="0"width="138"height="15"forecolor="#736343"/>
<textElement/>
<text><![CDATA[Hist Id]]></text>
</staticText>
<staticText>
<reportElementuuid="90d84a3f-e23f-4090-9db8-42fca0ced0ab"style="Column header"x="138"y="0"width="138"height="15"forecolor="#736343"/>
<textElement/>
<text><![CDATA[Date Due]]></text>
</staticText>
<staticText>
<reportElementuuid="50862542-096a-4072-8665-88c1238fa7c5"style="Column header"x="276"y="0"width="138"height="15"forecolor="#736343"/>
<textElement/>
<text><![CDATA[Total Amount]]></text>
</staticText>
<staticText>
<reportElementuuid="8e8735a4-a896-4eef-876a-0472fabf5493"style="Column header"x="414"y="0"width="138"height="15"forecolor="#736343"/>
<textElement/>
<text><![CDATA[Raw Data]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<bandheight="15"splitType="Stretch">
<frame>
<reportElementuuid="840d241f-46d5-4267-abf2-fbfabe77a1ba"style="Row"mode="Opaque"x="0"y="0"width="555"height="15"/>
<textFieldisStretchWithOverflow="true">
<reportElementuuid="904e88f2-9f49-494c-9e20-7a0f2a66c46e"style="Detail"x="0"y="0"width="138"height="15"/>
<textElement/>
<textFieldExpression><![CDATA[$F{hist_id}]]></textFieldExpression>
</textField>
<textFieldisStretchWithOverflow="true">
<reportElementuuid="745e034c-c2b7-406d-97b4-19f6a5a1f2ec"style="Detail"x="138"y="0"width="138"height="15"/>
<textElement/>
<textFieldExpression><![CDATA[$F{h_date}]]></textFieldExpression>
</textField>
<textFieldisStretchWithOverflow="true">
<reportElementuuid="c174e25f-9c68-4386-8968-1bda99810e3e"style="Detail"x="276"y="0"width="138"height="15"/>
<textElement/>
<textFieldExpression><![CDATA[$F{h_amount}]]></textFieldExpression>
</textField>
<textFieldisStretchWithOverflow="true">
<reportElementuuid="aa181d78-3fb6-47dd-ae2f-bc1aafba23ae"style="Detail"x="414"y="0"width="138"height="15"/>
<textElement/>
<textFieldExpression><![CDATA[$F{h_data}]]></textFieldExpression>
</textField>
</frame>
</band>
</detail>
<columnFooter>
<bandheight="45"splitType="Stretch">
<line>
<reportElementuuid="7c17f014-3c79-4265-b557-b38cf17c5f0f"positionType="FixRelativeToBottom"x="0"y="3"width="555"height="1"/>
<graphicElement>
<penlineWidth="0.5"lineColor="#999999"/>
</graphicElement>
</line>
</band>
</columnFooter>
<pageFooter>
<bandheight="25"splitType="Stretch">
<frame>
<reportElementuuid="1f9a92db-af7d-429a-ba60-a43bd78a783e"mode="Opaque"x="-21"y="1"width="597"height="24"forecolor="#D0B48E"backcolor="#F2EBDF"/>
<textFieldevaluationTime="Report">
<reportElementuuid="17fc328e-c16b-477d-a061-a733a9167907"style="Column header"x="533"y="0"width="40"height="20"forecolor="#736343"/>
<textElementverticalAlignment="Middle">
<fontsize="10"isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElementuuid="8087e1e6-d232-4090-97c3-72d455154cab"style="Column header"x="453"y="0"width="80"height="20"forecolor="#736343"/>
<textElementtextAlignment="Right"verticalAlignment="Middle">
<fontsize="10"isBold="false"/>
</textElement>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textFieldpattern="EEEEE dd MMMMM yyyy">
<reportElementuuid="2a3dc088-bcb4-4488-8bc8-7809bdaf9901"style="Column header"x="22"y="1"width="197"height="20"forecolor="#736343"/>
<textElementverticalAlignment="Middle">
<fontsize="10"isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</frame>
</band>
</pageFooter>
<summary>
<bandsplitType="Stretch"/>
</summary>
</jasperReport>

5. Preview your created report

Save and click on Preview to view the report .

6. Finally , Publishing the Report

a) Install the downloaded JasperReports Server and launch it .

Login the web interface with admin account .
username : jasperadmin
password : jasperadmin

b) Create a new JasperReports Server connection under repository tab in Jaspersoft Studio

c) A dialog to insert the server data appears. Fill it in as follows:

  • Name: the name of the connection. You can use any name you want. For this example we will leave the default name: JasperReports Server.
  • URL: the address of the server. The default address is already correct if we are using a local server. For this example the correct address is http://localhost:8080/jasperserver/
  • User: the username to access the server. The default for the local server is “jasperadmin”.
  • Password: as with the username, for the local server by default it is “jasperadmin”.

Then click the Test Connection button to test the connection. If everything is working, click Finish.

d) Open the report and click the button with a blue arrow in the upper-right corner of the designer. In the opened window you can browse the server directory structure to choose where to place the report. Select the Reports folder and name the report Then click Next.

e) Create the DataSource from Local Data source.

  • Select Datasource JDBC , click NEXT
  • Enter name and id then click next
  • Click Import from Jaspersoft Studio and Select BigSQL -> JDBC connection and click finish to create the datasource

f) On the web interface logged on with admin account , click on the folder Reports .

g) click on BigSQL published report to view it in the next screen