Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7940777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:28:31+00:00 2026-06-03T23:28:31+00:00

I am using Jasper plugin (v 1.5.3) for Grails (v 1.3.7). I have written

  • 0

I am using Jasper plugin (v 1.5.3) for Grails (v 1.3.7). I have written following code in a method of a Service

import org.codehaus.groovy.grails.plugins.jasper.JasperExportFormat;
import org.codehaus.groovy.grails.plugins.jasper.JasperReportDef;
import org.apache.commons.io.FileUtils;

class ReportService {

    static transactional = true
    def jasperService

    def generateFormA() {
        def reportDef = new JasperReportDef(name:'test.jasper', fileFormat:JasperExportFormat.PDF_FORMAT)   
        FileUtils.writeByteArrayToFile(new File('C:/test.pdf'), jasperService.generateReport(reportDef).toByteArray())

        return
    }
}

I am getting following run-time error when I call the Service method –

Cannot invoke method generateReport() on null object

I have injected jasperService and imported required classes as described in the plugin page. Moreover, when I debug, I noticed that reportDef is being instantiated properly.

Can anyone suggest anything. Appreciate your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:28:33+00:00Added an answer on June 3, 2026 at 11:28 pm

    Michael, thanks for the insight.

    To get a better idea about the scenes behind curtain, I downloaded the plugin source code and used directly in my application. Turns out, JasperService class of the plugin uses dataSource bean.

    class JasperService {
        boolean transactional = true
        javax.sql.DataSource dataSource
        .....
        private JasperPrint generatePrinter(JasperReportDef reportDef) {
            .....
            def conn = dataSource.getConnection()
        jasperPrint = JasperFillManager.fillReport(resource.inputStream, reportDef.parameters, conn)
            .....
        }
        ...........
    }
    

    But, dataSource is not being instantiated when dataSource.getConnection() method is called (which, in turn, throwing the null object error). May be this has something to do with Grails itself, not the plugin. So I modified the JasperPrint() method of JasperService class like below and it worked

    def dataSource = org.codehaus.groovy.grails.commons.ApplicationHolder.application.mainContext.dataSource
    def conn = dataSource.getConnection()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Grails Jasper report plugin in my application. Im trying to bind
I am using jasper reports and groovy/grails and i want to export report in
I am using groovy-grails with jasper reports to develop an app. I need to
I have a report to be exported in excel, pdf and word using jasper
Using LINQ on collections, what is the difference between the following lines of code?
We have a large web app installation, using Apache/Tomcat/Jasper and jboss. In development environment,
I get this exception: org.apache.jasper.JasperException: Unable to compile class for JSP I am using
I have a example for dynamic jasper report. I am using NetBeans IDE. I
in my grails application using jasper Reports i am creating report in pdf format,
I have a j2ee application using spring framework. I am trying to export jasper

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.