Griffon: Error when running report with JasperReports-Collection of common programming errors

I tried to run this code but it give me error like this:

2013-03-26 22:45:55,546 [pool-2-thread-1] ERROR griffon.util.GriffonExceptionHandler - Uncaught Exception
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NoClassDefFoundError: com/lowagie/text/SplitCharacter
    at org.codehaus.griffon.runtime.util.AbstractUIThreadHandler$1.run(AbstractUIThreadHandler.java:41)
Caused by: java.lang.NoClassDefFoundError: com/lowagie/text/SplitCharacter
    at net.sf.jasperreports.engine.JasperExportManager.exportToPdfFile(JasperExportManager.java:145)
    at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:497)
    at net.sf.jasperreports.engine.JasperExportManager$exportReportToPdfFile.call(Unknown Source)
    at report.ReportController$_closure1_closure2.doCall(ReportController.groovy:28)
    at report.ReportController$_closure1_closure2.doCall(ReportController.groovy)
    ... 1 more
Caused by: java.lang.ClassNotFoundException: com.lowagie.text.SplitCharacter
    ... 6 more

Here’s the code:

–ReportController.groovy–

import net.sf.jasperreports.engine.JasperCompileManager
import net.sf.jasperreports.engine.JasperExportManager
import net.sf.jasperreports.engine.JasperFillManager
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
import net.sf.jasperreports.swing.JRViewer

class ReportController {
    // these will be injected by Griffon
    def model
    def view

    def report = {
        def jasperParameter = [:]
            jasperParameter.REPORT_TITLE = "Test report"

        def jasperReport = JasperCompileManager.compileReport("report.jrxml")

        def mapData = [:]
            mapData.name = "abc"
            mapData.price = 1234
            def datas = [mapData]
                JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(datas)

        def jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, dataSource)

        JasperExportManager.exportReportToPdfFile(jasperPrint, "g:/sample.pdf")

        JRViewer viewer = new JRViewer(jasperPrint)

        viewer.setOpaque(true)
        viewer.setVisible(true)

        def jf = new javax.swing.JFrame ()

        jf.add(viewer)
        jf.setSize(800, 600)
        jf.setVisible(true)
        jf.setDefaultCloseOperation(EXIT_ON_CLOSE)
    }
}

–ReportView.groovy–

package report

application(title: 'report',
  preferredSize: [320, 240],
  pack: true,
  //location: [50,50],
  locationByPlatform: true,
  iconImage:   imageIcon('/griffon-icon-48x48.png').image,
  iconImages: [imageIcon('/griffon-icon-48x48.png').image,
               imageIcon('/griffon-icon-32x32.png').image,
               imageIcon('/griffon-icon-16x16.png').image]) {
    gridLayout (cols: 1, rows: 1)
    button (text: 'report', actionPerformed: controller.& report)
}

–report.jrxml– (I put this file in /staging folder)



    
    
    
    
        
    
    
        
            
                
                
                    
                
                
            
        
    
    
        
            
                
                
                    
                
                
            
        
    
    
        
    

I don’t quite know about .jrxml, i got this sample from the web, if I made a mistake please correct it.

Source: http://www.iaeronz.com/?p=562