I used Jasper report for the first time in my Grails project and i faced many issues. I am sharing some tips with you which will help you to solve common problems.

1. Use jasper plugin.
Go to this link and add jasper plugin in your BuildConfig.groovy like this.

 plugins {
	compile ":jasper:1.6.1"
	}

2. Configuration for path of jrxml file.
Jasper report provides default path for jrxml file which is “/web-app/reports/”. If you put your file here then no need to configure But if you want to put your jrxml file anywhere else then you need to provide “/path/to/jrxml/file” in environment of development and production . e.g.

environments {
    development {
        jasper.dir.reports = "/path/to/jrxml/file"
    }
    production {
        jasper.dir.reports =  "/path/to/jrxml/file"
    }
}

3. Download file using jasper.
For downloading file you need to write syntax like this.

<g:jasperReport controller="controllerName" action="actionName" format="PDF" jasper="report2">
</g:jasperReport>

where format is file format in which you want to download your file and jasper have name of your jrxml or jasper file.

In action you can write like this.

Class controllerName{
def jasperService
 Def actionName(){
 Map result = [:]
        result.data = []
        result.data << [name:”vivek”,surName:”yadav”] // from here you can send any type of data  
  // what ever you want
        JasperReportDef rep = jasperService.buildReportDefinition(params,request.locale,result)
        ByteArrayOutputStream stream = jasperService.generateReport(rep)
        response.setHeader("Content-disposition", "attachment; filename=" + 'fileName' + ".pdf")
        response.contentType = "application/pdf"
        response.outputStream << stream.toByteArray()
}

Here is your jrxml file named “report2.jrxml”.

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="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="report2" language="groovy" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="4609b597-87e0-42d5-b9fb-5f86a41d01a0">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<style name="Title" fontName="Arial" fontSize="26" isBold="true" pdfFontName="Helvetica-Bold"/>
	<style name="SubTitle" forecolor="#666666" fontName="Arial" fontSize="18"/>
	<style name="Column header" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/>
	<style name="Detail" fontName="Arial" fontSize="12"/>
	<field name="name" class="java.lang.String"/>
	<field name="surName" class="java.lang.String"/>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="70" splitType="Stretch">
			<textField>
				<reportElement uuid="03b9a4c5-59da-4df7-9435-835eda1e83aa" x="0" y="0" width="316" height="20"/>
				<textElement/>
				<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="712c4332-946e-40dd-aa9e-a68fea55c1f9" x="316" y="0" width="239" height="20"/>
				<textElement/>
				<textFieldExpression><![CDATA[$F{surName}]]></textFieldExpression>
			</textField>
		</band>
	</title>
	<pageHeader>
		<band splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band height="36" splitType="Stretch"/>
	</columnHeader>
	<detail>
		<band height="16" splitType="Stretch"/>
	</detail>
	<columnFooter>
		<band height="45" splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band height="20" splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band splitType="Stretch"/>
	</summary>
</jasperReport>