No thread-bound request found error in controller promise #19
Description
Thanks for reporting an issue for Grails Async, please review the task list below before submitting the
issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.
NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (http://stackoverflow.com/tags/grails) or Slack (http://slack-signup.grails.org). DO NOT use the issue tracker to ask questions.
Task List
- Steps to reproduce providedStacktrace (if present) providedExample that reproduces the problem uploaded to GithubFull description of the issue provided (see below)
Steps to Reproduce
I am trying to upgrade a grails 2.5.4 application to grails 3.3.2. Some of the codes used to work now couldn't work. Basically, the issue is that the async task in the controller is referencing request.params which is not available in the async thread.
I created a 2.5.4 project (demo254) and a 3.3.2 project (demo332) to demonstrate the issue. Both projects have the same controller and view code.
Please refer to the readme in https://github.com/ruiyang/grails-issue-demo.git to reproduce.
Expected Behaviour
I am not sure about the expected behaviour. I just need to know if there is any way I could get this code working to avoid a lot of rewrites.
Actual Behaviour
Exception:
URI /helloWorld
Class . java.lang.IllegalStateException
Message . null
Caused by: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
Environment Information
- Operating System: MacOs
- Grails Version: 2.5.4 VS 3.3.2
- JDK Version: 8
Activity
jaguar1975cn commentedon Jun 25, 2018
I have the same issue on 3.3.6. Any news about this problem? Thanks
mortensoby commentedon Jan 8, 2019
I have the same problem with 3.3.9
ppazos commentedon Sep 16, 2021
I have found using this in controllers and running integration tests will cause the problem, I'm on Grails 3.3.10: