06 December 2009

Jasper Reports - How to deploy a report to Jasper Server

In the previous article, we created our first report with iReport.

Here, we're going to deploy it to the server.

First, we need to connect iReport to the repository. Select JasperServer Repository in the Window menu to show the repository navigator:

Select JasperServer Repository

Then click on 'Add new server' to create a new server:

create new server

Enter a name, and the username and password (for the samples jasperadmin/jasperadmin), and save. If we then click on the server in the repository navigator, we get the following:

reports and data sources in the repository

With Jasper, you need to define the data sources for a report. For the preview, the local data source is used, but to display the report from the server, you'll need to define one on the server as well.

In the repository explorer, select the Data sources folder, and right click, select Add->Data Source:

Add new server datasource

Enter a name and a label, and then click on the Data Source Details tab. If you select JDBC data source, you then have the option to 'Import from iReport', where you can select a local data source.



The list of reports in the repository navigator corresponds to the list displayed on the web (see Jasper Reports - Getting Started.)

You can deploy the TABLES report defined in Jasper Reports - Exploring iReport. Now you need to create a Report Unit. A Report Unit is a report plus the data source and any parameters necessary.

We'll create a folder Reports/Test. Then right-click and select Add->Report Unit.

Add Report Unit

The wizard is displayed. Select a name, label and description:

Report Unit enter name, etc.

And the .jrxml file. This is the report1.jrxml containing the report you defined earlier.

Report Unit select datasource

And finally a datasource:

Report Unit select jrxml file

And then the report is available from the web site:

website list of reports including TABLES report

And finally, we can display the report:

TABLES report from the server

Next, we'll look at how to update and redeploy a report to the server. Next>>

3 comments:

Anonymous said...

The best way to deploy or publish a report is using the jdeploy tool on https://sourceforge.net/projects/jaspertools/?source=directory

it allows deal with the datasources problems on the diferent environments, dev, preproduction and production.

Matthew Farwell said...

Thanks. I'll look at that.

Unknown said...

Many thanks for the very useful article!