Grails-Jasper plugin starter issues..

Jasper is one of the better solutions on the reporting side from the open-source perspective.  Also, Grails has been growing in popularity as the chosen framework to write web-apps which were ought to be written in Java.

In this post, I’ll stick to the grails-jasper plugin. It expects you to know basics of grails and jasper.

Off we go then..

On the editor side, I prefer Eclipse and eclipse-plugin JasperAssistant than iReport. There are many advantages with that. It is much more simple & lightweight.
Regarding the issue with Grails, I went ahead with installing the plugin and was able to generate reports.

One great help was:
after installing the plugin, go to the url

It gives few sample implementations of the jasper plugin. Once they’re working, you’re set to use the reports.

Some issues I faced were:

Issue : report/MyReport.jasper or .jrxml not found.

Solution: Need to create a report folder in web-app and copy all the .jasper & .jrxml files there.

Reason : The plugin expects the files to be there. It can be modified by changing the configuration.groovy file.

Issue : PDF(output) is empty

Solution: Data is not bound to the report file.

My solution was I created my own Controller to access data and pass it to jasper (instead of the default jasper query)

class ReportController {


def testExample = {
// This “data” object in this data model is the data that drives this Jasper report (i.e. what appears in the
// detail band)

List reportDetails = Race.list();


// here jasper is the plugin provided controller.
// and index is the default method in jasper controller.
// we need to pass the data and the params.


list.gsp (front end) has the following tag

<g:jasperReport controller=”report”              >> calls the report controller
jasper=”all-races”            >> the jasper file
action=”testExample”        >> the action(method) in the controller
format=”pdf”            >> format can be pdf, excel, etc.
name=”ReportFile”            >> Name of the file exported

all-races.jrxml (report file) has the following lines

// fields provided to the report. They’ll be equivalent to the Object provided in collection.
// e.g. List<Person>, Person class would be available and each field is its attribute.

<field name=”name”/>
<field name=”city”/>

// usage of the field:

<textFieldExpression   class=”java.lang.String”><![CDATA[$F{name}]]></textFieldExpression>
<textFieldExpression   class=”java.lang.String”><![CDATA[$F{city}]]></textFieldExpression>

I hope it helps.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s