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

  • Home
  • SEARCH
  • 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 8448871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:32:31+00:00 2026-06-10T10:32:31+00:00

I have a very similar problem to the one described in this question .

  • 0

I have a very similar problem to the one described in this question. (The main difference being that i am using Grails 2.1).

Basically i want to write a unit test which does sth like:

// set params so i can create an obj.
def results = controller.save()

// validate results or model/view
results = controller.edit(id, version)

However, this doesn’t work, because the first method action (save) has triggered a redirect and the second one would too, which leads to a CannotRedirectException.
With the message:

Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response.

The proposed solution for this (found in various places) is:

redirectArgs.clear()

However, this doesn’t work, because since Grails 2, redirectArgs doesn’t exist, there is only

response.redirectUr

which can only be read, not written to.

I have also already tried these things (in various combinations):

response.reset()
clearGrailsWebRequest()
bindGrailsWebRequest()
cleanupGrailsWeb()
controller.redirect([:])
controller.redirect(null)
controller = new OfferObjectController()
controller = mockController(OfferObjectController)

All without any luck.

I have totally run out of ideas what else could work/help.
Any suggestion is appreciated!

==== EDIT ====

i forgot to clarify that

response.reset()

kind of works, it lets me call another action, however it seems to undo/rollback the changes done by the previous action, which is exactly what i want to avoid (if i wanted that, i would put the call into its own test[method]).

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

    The answer is

    response.reset()
    

    I don’t know why you’re receiving that exception. By the way, you should create one task one test.

    I guess you can try this:

    import org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest
    .....
    
    // set params so i can create an obj.
    def results = controller.save()
    
    def lastRequest = GrailsWebRequest.lookup().currentRequest
    lastRequest.removeAttribute("org.codehaus.groovy.grails.REDIRECT_ISSUED")
    
    // validate results or model/view
    results = controller.edit(id, version)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem very similar to the one mentioned in this question .
I know that this is a repeated question. I have found very similar questions
I have a problem which seems very similar to the one described in http://markmail.org/message/6rlrzkgyx3pspmnf
I have an error very similar to the one addressed in this question .
My current problem is very similar to this one . I have a downloadFile(URL)
I have a problem very similar to this one , but slightly more involved.
I have a problem very similar to the one described here: https://microsoft.public.win32.programmer.kernel.narkive.com/Ly2P8Yp2/prevent-vista-from-marking-my-application-as-non-responding That thread
I have a problem very similar to this one : CATransaction Not Animating I'm
My problem is very similar to this question , however I am posting a
I've worked on projects that have very complex XML configuration, and one problem that's

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.