Planet Jaspersoft

August 17, 2015

This is an error which you get while exporting the data from the Jasperserver in the Excel Format.

Something of this sort

For resolving this you should check some of these errors:

1. Number to string cast exception:
This means that a number is wrongly appended to a string in which wrongly cast number into string.
In order to fix this, you will have to use the command as

new DecimalFormat("##,#0.00").format(number).toString()
This will cast your number into two decimal places with the thousand separator.

2. Another error that can be checked is of any other cast errors, or formatting of the data in the report.


August 17, 2015

February 11, 2015

I wanted to document the process from a long time but due to crunch of time I could not, but now I will like to explain the process in simple easy to follow steps.

First of all I would like to give an idea to problem addressed in the blog, basically when a report runs as a daily status or daily count one need not run it manually it could be scheduled, but when the report is scheduled the export in desired form is exported on jasper server.

But wait a minute do we really login and see what the results came as in the PDF, Excel etc. export, no we need not the problem is handled by mail subscription attached to the scheduler, which will automatically send the Exports to the subscribers on their email accounts and send a confirmation to the administrator.

So lets cut the explanation and lets jump directly into how to do.

Prerequisites -

1. You should have working copy of JasperServer community/pro
2. You should have uploaded a report to the server
3. Choose you favourite text editor  (Windows(default) - Notepad/MacOS(default) - TextEdit)
4. Shut down the jasper server so that no sort of errors come in case of Editing/Saving documents.

after following the above prerequisites now we head on to edit two files as follows.
Both these files will be found at the location
<directory of Jasperserver on Disk>/apache-tomcat/webapps/jasperserver/WEB-INF/

   - Edit the file with the Text Editor
Change the portion of the document as (Please select your own server details I have used a gmail account )
report.scheduler.mail.sender.protocol= smtp
report.scheduler.mail.sender.port= 587
  - Make the changes and save the file.

2.   applicationContext-report-scheduling.xml

  -  Locate the bean reportSchedulerMailSender
  -  Locate the property javaMailProperties
  -  Do the changes as below - This will enable java to interact the smtp/startls authentication.      

                <prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
  - Now save the document.

Now the report subscription is ready for run, just start the Jasper Server and you are good to go.


February 11, 2015

January 20, 2015

In this blog I have explained the steps to import and export the JasperServer Repository (In the steps below I have used a Remote Linux Machines accessed via windows machine)

Before following the steps there would be requirement of following softwares-
1. WinSCP - To browse the files in Linux machine
2. PuTTy - To run the commands for export/import in the Linux shell

Steps Export reports in Jasper Reports

1. Open PuTTy - and key in the IP address 
2. Enter the username and password.
3. Navigate to the folder /opt/jasperreport-server-5.0/buildomatic
4. Run the command  ./ --uris <Path of the Report>  --output-dir <Name of the folder to be exported>
5. Open the WinSCP, and key in the  IP Address as well as the credentials and set the Protocol as SFTP .
6. Navigate to the folder /opt/jasperreport-server-5.0/buildomatic
7. Drag and drop the folder created earlier to the local machine.

Steps Import reports in Jasper Reports

1. Open the WinSCP, and key in the  IP Address as well as the credentials and set the Protocol as SFTP .
2. Navigate to the folder /opt/jasperreport-server-5.0/buildomatic
3. Drag and drop the folder downloaded with the report.
4. Now Open PuTTy - and key in the IP address 
5. Enter the username and password.
6. Navigate to the folder /opt/jasperreport-server-5.0/buildomatic
7. Run the command  ./ --input-dir <name of the folder copied earlier>

January 20, 2015

January 12, 2015

I have been thinking to compile  a document which outlines the complete process of installation and setup of the connection because generally when one starts they do not find much of material and they tend to get stuck on a trivial issue.

So the post will have two portions, namely Installation and Setup.


This document will apprise you with the basic installation software, which would act as a prerequisite to run Jasper Report.
  1. Java
    As Jasper Reports is built on Java platform, so a proper installation of Java Development kit (jdk) is required. For official steps to install java one can refer to the link
  2. iReport Designer
    This is a third party Jasper Report designing software. iReport is the most popular visual designer tool for JasperReports Library and JasperReports Server (Business Intelligence).
    The software can be downloaded in an exe run able format for windows machine, or other types of files as per the platform demands.

  3. Jasper Server
    This is the software which acts as the interface which provides web touch to the reports rather makes it interactive in terms of external links and the drill downs
    Below is the link from where the file could be downloaded.

  4. Database  Server -
    The database server or the datasource which serves the purpose of feeding data to the report, in this projects case the setup was in the SQL Server 2008, which could vary from project to project .
  5. Netbeans(Optional)

Netbeans is the development environment where in you could create sciptlets for customization purposes in the Jasper Reports. You could even go on to make customizations on the charts, where in you could use the (Download the SE version)

Setup and Connection

Below are the steps for the setup, which would act as a prerequisite to run Jasper Report.
  1. Java
    Download and install java 7, please do mind not to install Java 8 as it is yet not supported by iReport.
  2. iReport Designer
    After installing the iReport, first thing you need to do is that the inclusion of java connector

    Below is the process to include the Java Connector

    i.  Download the Java connector for the Datasource, as we have the SQL Server datasource we need to download
    For more info on the Connector follow the link --

    ii.  Navigate to Tools—> Options  Classpath
    And select the Add JAR, and then browse to the downloaded path of the connector

    Now we  need to add a JDBC datasource

    i. Click on  the icon shown below on the top of the iReport window

  1. ii.  In the popup select New  Select The Datasource type as Database JDBC Connection

    iii. Now Enter the name of the connection, select the SQL Server driver and enter the name of the database in the url of the database, also key in your credentials, refer to the screenshot below

    iv. Now test the connection, it will say the connection successful.

    We are now ready to create reports.

  2. Jasper Server
    After installation in order to run Jasper Server open the browser and key in
    Then login using the credentials jasperadmin/jasperadmin

    Then setup the connection, righ click on the node and add a datasource
    Enter the details below,  for the connector and setup the datasource.

The above steps are pretty basic and gives a fair idea as to what all basic necessities are there to process the installation and setup.

January 12, 2015

November 20, 2014

 This Exception comes generally when you try to export the report on Jasper Server in PDF Format, or from iReport, then due to the error in some of the image or all the images, which is producing the error.

So to overcome this issue, you could set following properties of the image:

1. Firstly you could simply setting the Cache Property to true
2. If that does not resolves the issue then you can set the property Error type to Blank

Hope that this helps.


November 20, 2014

November 2, 2014

Jasper Reports Server is basically a stand alone as well as embedded  reporting server which can be easily used for deploying the Jasper Reports. It provides a way to embed reports as well as analytics into a web or mobile application, as well as act a informational hub.

Server is made to securely share and manage the Jasper reports and analytic views. The security feature is implemented via role management and user creation facility in Jasper Server.

Now there are two ways you can use Jasper Server
1. Standalone application
2. Embed into services, or applications.

Now moving on to the Source Code Management,

    What benefits do Source Code Management tools provide?

SCM tools help development teams in many ways:
  • Collaboration: SCM tools prevent one user from accidentally overwriting the changes of another, allowing many developers to work on the same code without stepping one each other's toes.
  • History: SCM tools track the complete development history of the software, including the exact changes which have occurred between releases and who made those changes.
  • Release notes generation: Given the tracking of each change, the SCM can be used to generate notes for their software releases which accurately capture all of the changes included in the new release.
  • Documentation and test management: SCM tools can be used to manage not just software source code, but also test suites and documentation for their software.
  • Change notifications: To keep interested members of the team informed when changes occur to the source code.

   Who uses SCM tools?

SCM tools are used by:
  • Project developers who are writing source code.
  • Project testers who need to download the very latest changes.
  • Advanced users who want to try out code that is not yet stable, mature or released.

In JasperServer, the SCM is managed very intelligently, whenever you draw a report for viewing in then you always get a version of the report, so you are not really modifying what is there on server. 

Jasper Server always keeps the original content on the server and provides the user with an instance of the report which is directly stored in the Temp folder, and if you need the modified version you have created as the current version then you need to replace the report with the current version of the report, by right clicking on the report in the repository and then replacing the report.

In light of this feature there is also a extreme care to be taken that which version is being replaced, because if once replaced the version of the report will be changes and it would be not possible to roll back the change.

This feature is really very great when you need to work on the small modification in the report as you can draw a copy on the local system and work onto that until you get the desired modification as well as you can simultaneously compare the previous version of the report and if you get the desired changes executed you can replace the report and have a new version of the report.

Hope this information helps you a lot!!

November 2, 2014

September 16, 2014

CrossTabs are used for creating statistical view of a large sample data.

They allow you to summarize a huge unorganized data to be organized in terms of commons between the data.

Suppose You have a data containing two columns Year, Brand of the car sold

Some thing like this 


Now if you have to tell the total sales of Audi  in 2000,2001,2002. It will be a long and tedious process, so to show it Schematically We can have Distinct Years and Distinct Car Brand Names for representing the data as they are the are the common attribute to the data .

So the statistical data will look like this

In the table above you could easily determine the Number of car sold for either of the brands and in which specific year. Also The last column where the the two totals converge i.e. 16 shows you the total value of the sample. 

Now let me quickly move on to implementation of Cross Tab in Jasper Reports rather iReport.
For the tutorial I would be using the iReport v5.6.0

1. The data needs to be retrieved from a datasource (either JDBC/JavaBeans/Custom Datasource/Excel/CSV... etc)
2. For the demonstration purposes I will be using the Excel File as the datasource.
3. After defining the datasource, we need to add the CrossTab element from the pallete.
4. Pallete could be accessed, Window( Menu Bar) --> Pallete, then from there the CrossTab could be found under the Report Elements.
5. As soon as we drag the Pallete, we get an wizard as below,

  •     Select the datasource, if subdataset is created then we can use that or simply the main dataset could be used. For the tutorial Main dataset is used
  • Next will appear the grouping criteria for the rows which in short means that which field(s) will come on the Rows of the Cross Tab. We need the car companies on as the rows which are unique.

  • Next will appear the grouping criteria for the Columns which in short means that which field(s) will come on the Columns  of the Cross Tab. We need the Years on as the rows which are unique
  • Next will be the Measure or the count of the value in particular grid.
    Which in our case would be the number of cars of a particular company in a particular Year

  • Then will come the window to select the layout of the crosstab, this means here we can customize the looks of the cross tab by defining the colors and which columns to show/hide.

    6. Now this brings to the completion of the crosstab, now we could see that a tab at the bottom left corner appeared showing the name of the Crosstab, as Crosstab 1. There we could see the columns and design of the Crosstab.

    7. Now a very critical point is placement of the crosstab, this should be really placed in a report band wherein the data is calculated already and then is to be shown in crosstab, the most favorable band to show the CrossTab is Summary band, else it will throw an Error Incrementing crosstab dataset/ Crosstab already been processed.

    Now to Explain the exception
    What "Crosstab data has already been processed" exception means?
    This exception is thrown if more data is added to the crosstab dataset after the crosstab has already been rendered.
    This usually happens when a crosstab element is linked to the main dataset of the report (does not use a subdataset run) and the resetType attribute of the crosstab dataset does not match the place where the crosstab is rendered.
    Crosstabs are special components that display aggregated data. And when they are linked to the main dataset of the report, you simply cannot put them in the detail section, because there is no data to aggregate from a single record.
    Such crosstabs could only reside on a group footer or on the summary section of the report and have the appropriate resetType value, so that their dataset is initialized each time after they are rendered.
    If you still think you need to render one crosstab for each detail in the master document, then almost certainly this crosstab should be linked to a subdataset and not to the main dataset of the report.

How to set up the tutorial Report:

1. Unzip the file downloaded from the above link.
2. The Zip contains sampleds.xls, CrossTabTut.jrxml and TestRun.pdf
3. Open iReport and set up the Excel Datasource using the sampleds.xls
4. Then open the sample report and its ready to run.

Hope that this helps!!

September 16, 2014

September 12, 2014

This post is the first in a series of posts that will accompany the release of our ElasticJasper software in the wild world of the open source. It may be not perfect, we have been postponing its release as open source for a while because we can make it even better, but we have been using it daily in production environments and – while far from perfect – has been very useful.

Adapting the data view of ElasticSearch to the one that Jasper Reports has was not simple. Some sacrifices were made to make it simple to use while keeping most of the elasticity – no pun intended – of ElasticSearch. One of the compromises – as we will see in detail later – has been to make every datasource created with the adapter dedicated to an aspect of the many possible ways that ElasticSearch returns the data.

All  that it’s needed – and that we use – to compile the plugin and the server adapter is available right now on GitHub. You can start cloning and forking from our Open Initiative Repository.

But lets dive right in and see what this release is all about.

Installing the plugin

In this first post we will see how to install the plugin in Jaspersoft Studio and start creating some reports. It will help if you have a Kibana3 installation somewhere, since this would make creating your queries quite simple – at least for hits and facets.

Open up your Jaspersoft Studio – versions 5.6.0 and above are supported – and choose the “Install New Software…” entry in the “Help” menu. If you – like me – are wondering why installing software is in the context of helping, I have no answer to that.

Install Software - Step One

First step in installing the plug-in.

At this point you can choose to add a repository. The repository you need to add – where the binaries of the plugin are currently archived – is at the moment hosted also on GitHub. Pick any name for the repository and for the “Location” enter:

  You should now be presented with something that looks like:

Install Software - Step Two

Install Software – Step Two

Select the only available plugin and click “Next“. You will then be prompted to accept the license, then you will be warned that you are installing unsigned content and finally you will be asked to restart. Do all of the above and you have installed ElasticJasper!

Creating an adapter

When Jaspersoft Studio starts up again right click on “Data Adapters” – in the “Repository” tab – and choose to create a new adapter. In the list of the available adapters you should now see one called “ElasticSearch DataSource”. Select this one and click “Next” – this is where the first magic happens!


Adapter Options

The adapter options wizard step.


This bit needs some explanation,  but it shouldn’t be too difficult if you are already familiar with ElasticSearch.

  • Indexes and Types: you can leave these empty or list – separated by commas – the indexes and types of documents that you want the queries to apply to. If you leave it empty the queries will be ran on all the indexes and document types;
  • Hostname, Port and Cluster: these parameters are quite self explanatory. “elastic search” is the default cluster name, so if you haven’t changed it you should leave this at the default value; same thing goes for the port – 9300 is the API port, don’t confuse it with the web services 9200 port. Practically you should just change the hostname to the name or address of one of the nodes of your ElasticSearch installation, the client will find the others;
  • Username and Password: if access to your ES server is protected by username and password, as you may have already guessed, this is where you would enter them;
  • Query Mode: this is the odd bit. When you run ES queries you may end up with results that are either hits – if you searched for actual documents, facets – used to get metrics and other summary information about your data or aggregations – the latest and best way to get summary data out of ES. Or – if your query is complex enough – the response could contain all of the above. To make it easier on the parser – also because it would be difficult to mangle all these different types of data in the same table format – you will have to have different adapters for the three different types of queries. So one adapter will specialise in getting hits from the ES cluster, one will get facets and one will get aggregations.

In our first example we are going to get some facets data – getting it by copying a query from Kibana3. So you may want  to select “Facets Mode” as your query mode once you have setup your ES connection. Press “Test”, and if all is well you have created your first ElasticSearch to Jasper Reports adapter.

Using your adapter

Start by creating a report as usual – right clicking on the projects menu and choosing to create a  new report, when you get to the choice of an adapter choose the one that you have created before. You will see that you will be presented with a text area for you to enter the ES query. We want facets – that’s the kind of adapter we have created – so we can write a query along these lines:

 "facets": {
   "LostConnections": {
     "date_histogram": {
       "field": "dt",
       "interval": "1d"
     "global": true,
     "facet_filter": {
       "fquery": {
         "query": {
           "filtered": {
             "query": {
               "query_string": {
                 "query": "evt:\"LostConnection\""
             "filter": {
               "bool": {
                 "must": [
                     "match_all": {}
 "size": 0

What this query is all about: it creates a facet query named “LostConnections”. This facet is a “date_histogram” facet, in other words: it will collect data grouped by time – the field containing the time is called “dt” and the interval we have chosen is one day. The query is filtering, returning only the count of documents that have a field “evt” matching “LostConnection”.

In other words: it returns for each day connections where reported lost how many times it happened.

You can now click “Next” – the adapter will show you a list of fields that the query returned, do your usual business with it, selecting the fields you want to report on and then the ones you want to group.

Your report is served!

A couple of things

There are a couple of things that come handy when handling reports that are using data coming back from ElasticSearch. Following, in some kind of random order, are a couple of things I wish I knew myself when I started playing with ElasticSearch and JasperReports.

Time – the ElasticSearch way

ES uses Unix Epoch time to represent timestamps. In other words: the number of seconds since the Epoch. These timestamps are king of meaningless to the human eye. I started creating formatters and adding them as parameters in the reports, so that I can instantiate them once and use them all over the reports.

I can create then a parameter called “WEEKDAYFORMATTER”, of type java.text.DateFormat, and use the following expression to populate it:

$P{REPORT_FORMAT_FACTORY}.createDateFormat("yyyy/MM/dd EEE", $P{REPORT_LOCALE}, TimeZone.getTimeZone("GMT+2"))

What this does is to create a date formatted with a weekday in it, using the report locale and the Italian timezone (GMT+2). The string this formatter would be giving out is something in the lines of: “2014/09/12 Fri”.

The way you then use it to format a timestamp field would be using an expression like:

$P{WEEKDAYFORMATTER}.format(new Date($F{Time}))

Where “Time” is the field I want formatted in the report. You can change format, locales and timezones and just have one formatter for each flavour that you want to use in the reports.

Grouping – not without sorting

If you decide to group by some of the fields returned by an ES query you have to remember that there is no guarantee that the fields will be returned sorted. You may end up with a report with an alternating series of the same groups, and it’s not nice.

To make sure that this does not happen you have to ways:

  1. Using the wizard to create the grouping: there is a checkbox on the wizard panel you will see when selecting the fields to group with, it allows you to automatically sort by the selected fields – check it!
  2. You created the grouping – what now? You created the group on the wizard, forgot to check the box, now you report has a lot of repeating groups. What to do? Simple: add the fields in the “Sort Fields” node of the design outline. Right click on it and create a “Sort Field“.

Subreports – when to create new connections

When you create sub-reports you can recycle the connection from the master report. That’s all fine, until you want to use some kind of different query results in the subreport. So: your master report is using a ElasticJasper adapter for facets and you want to use aggregations on the sub reports: you will need to create new adapters for these sub reports. I know – it sucks, but so many things suck in life, why would you want to be worried about this one?

If your main report is an empty vessel for your sub reports – and it has a data adapter you want to use on your sub reports, but a query that returns no data in it, remember to check the “When no data” property of the report – it’s on the report root node in the outline under the “Report” tab of the properties. It needs to be: “All Sections No Detail” so that it will run the sub reports.


September 12, 2014

March 24, 2014

Using Styles in Jasper Reports (Ankur Gupta)
AgileTech - Ankur Gupta )

We have been accustomed to use style sheets or CSS in our HTML codes, parallel to that we can use Styles in Jasper Reports also. It provides same utilities like conditional, non -conditional and could be applied on  any element in the Report.

Now how to create styles, there are two methods basically:
1. External Style Sheet (jrtx file)
2. Declaring Internal Styles in the report itself.

The advantages of using external Style sheet is that it provides modularity and re-usability of the style over large number of reports using similar kind of styles. On the other hand, Internal styles would only contains the styles definitions for a particular report.

How to apply styles in the reports(iReport).

1. Locate the Styles node in the Report Inspector.
2. Right Click on the node and add a new Style
3. Then you could define the properties of the Style in the in the properties pane. Properties like background-color,forecolor, outline,.. etc/
4. You could even click on the Style and add a conditional Style and define conditional styles, like alternate coloring and much more.
5. After defining the styles now in the application part, locate the element onto which you want to apply the style.
6. Select the particular style in the property called Style(could be found in the properties pane) of the Element.

I have created a simple tutorial video demonstrating the Styles in Jasper Reports. Click Here

Download the sample demonstrated in the video tutorial from here. The ZIP file contains :
1. The JRXML File
2. The jrtx Style.

The Sample uses the Sample database so no need to worry about the datasource.

Happy Coding.

March 24, 2014

Many a times we require the name of the person who logged into the Jasper Server and according to this information we are able to show/hide the elements on report, or simpley to log the user name we can use it.

So how to achieve this ? 

We can create parameters in our report, with a specific name and datatype. Then these parameters will be automatically filled when the report is executed by JasperReports Server.
LoggedInUsername (java.lang.String), with no default value. Then, we can use $P{LoggedInUsername} in a text field, in a query, in a printWhenExpression, etc ...
This is a built in parameter which gets filled with the User Details when report is run on Jasper Server.
Note that the report if run in iReport, would get a null value. So for the correct results it is necessary that we deploy the report onto JasperServer.

Parameter Name
Not usable in query input control,
 but is used as parameter to report
Of logged in user
Of logged in user
Of logged in user
Is logged in user enabled?
Is logged in user externally defined?
 ie. authenticated externally
Of logged in user. Only relevant in 
Current set of roles of logged in user. 
Useful for $X parameter
Map<string, string>
Not usable in query input control, but is 
used as parameter to report.
 Empty map if no attributes
User profile attribute names. Useful for
 $X parameters. Empty collection if no
LoggedInUserAttribute_<attribute name>
Attribute value for matched attribute name (like "att1") on the user. Empty string if no match. Only provided if defined in a query or as a report parameter.

Using the above parameters we could easily get various important information which could help in defining the roles. 

Happy Coding.!!

March 24, 2014