Grails错误:找不到线程绑定请求:您是否在引用请求属性...安装Spring Security Core之后

황현정*_*황현정 12 grails spring-security illegalstateexception


我刚刚创建了一个新的grails-app,
一切都很好,直到我决定
安装Spring Security Core.

安装Spring Security Core
执行s2-quickstart并点击
grails run-app后,产生了
以下错误:

URI
/test1/
Class
java.lang.IllegalStateException
Message
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.
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这个问题?
如果
你能提供帮助我真的很感激.我曾尝试
在其他网站上寻找答案,但
我无法解决.:)
BTW,我正在使用:
Spring Security Core 1.2.4
Grails 2.0.0.RC1

Mat*_*adt 16

如果你正在使用Maven,请确保你的pom.xml上有这个:

<dependency>
    <groupId>org.grails.plugins</groupId>
    <artifactId>webxml</artifactId>
    <version>1.4.1</version>
    <scope>runtime</scope>
    <type>zip</type>
</dependency>
Run Code Online (Sandbox Code Playgroud)

在BuildConfig中,groovy:

runtime ":webxml:1.4.1"
Run Code Online (Sandbox Code Playgroud)

这为我解决了Grails 2.2.0的问题.

  • 这在Grails 2.2.3中修复了它,spring-security-core 1.2.7.3,谢谢! (2认同)

Par*_*udy 7

如果您使用的是旧版本的Spring Security Core,则会发生这种情况.我从grails 1.3.7(和spring security 1.1.3)升级到grails 2.0.0时遇到了这个问题.修复是在application.properties中更改为spring-security-core 1.2:

plugins.spring-security-core=1.2
Run Code Online (Sandbox Code Playgroud)

更多信息,请访问http://jira.grails.org/browse/GPSPRINGSECURITYCORE-98,황현정建议.