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 9040981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:07:33+00:00 2026-06-16T10:07:33+00:00

I have some code that I am trying to port from Grails 1.3.7 to

  • 0

I have some code that I am trying to port from Grails 1.3.7 to Grails 2.2.

The current problem is that I have an BaseController class that defines some convenience methods, and specific controllers (ones actually instantiated by Grails) that inherit from it.

package com.fxpal.querium

import grails.converters.JSON
import groovy.lang.Closure;

abstract class BaseController {

    protected def executeSafely(Closure c) {
        def resp = null
        try { 
            populateContext();
            resp = c() 
        }
        catch(Exception ex) {
            resp = [error: ex.message]
            ex.printStackTrace()
        }
        def json = resp as JSON
        return json
    }

    protected void populateContext() {

    }
}

An example of a derived class is

package com.fxpal.querium

import grails.converters.JSON
import grails.plugins.springsecurity.Secured
import javax.servlet.http.HttpServletResponse

@Secured(['IS_AUTHENTICATED_REMEMBERED'])
class DocumentController extends BaseController {

    def grailsApplication

    @Secured(['IS_AUTHENTICATED_ANONYMOUSLY'])
    def getText = {
        try {
            String text = new URL(grailsApplication.config.querium.docurl + params.paperId).text
            render contentType: 'text/plain', text: text            
        }
        catch(Exception ex) {
            render contentType: 'text/plain', text: "Error loading document: ${ex.getMessage()}; please retry"
        }
    }

...
}

This worked in Grails 1.3.7. When I try to compile my app with Grails 2.2, I get the following error:

C:\code\querium\AppServer-grails-2\grails-app\controllers\com\fxpal\querium\DocumentController.groovy: -1: The return ty
pe of java.lang.Object getGrailsApplication() in com.fxpal.querium.DocumentController is incompatible with org.codehaus.
groovy.grails.commons.GrailsApplication getGrailsApplication() in com.fxpal.querium.BaseController
. At [-1:-1]  @ line -1, column -1.

Is this pattern no longer supported? I tried adding abstract to be BaseController declaration (it wasn’t necessary in Grails 1.3.7), but that didn’t seem to make any difference. I compiled my code after a clean, if that matters.

PS: To those who can: please create a grails-2.2 tag

  • 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-16T10:07:34+00:00Added an answer on June 16, 2026 at 10:07 am

    Remove def grailsApplication – the field is already added to the class bytecode via an AST transformation as a typed field (GrailsApplication) so your def field creates a second get/set pair with a weaker type (Object).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some code that i am trying to recompile and understand, but i
I have some legacy C++ code that I am trying to understand a bit
Trying to get comfortable with jQuery and I have encountered some sample code that
I am trying to setup a few fixes in some code that have caught
I am trying to convert some Verilog code that produces a slower clock from
I am trying to port some C++ code from Windows to Solaris(Unix). There are
I'm trying to port some windows code that uses HidD_GetInputReport to linux using libusb.
I'm trying to figure out some C code so that I can port it
I am trying to port some code written in MATLAB to C, so that
I am trying to port some code I wrote from Mac OS X to

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.