12


我刚刚创建了一个新的 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.

有人知道如何解决这个问题吗?
如果您能提供帮助,我将不胜感激
。我曾尝试在其他网站上寻找
答案,但
我无法解决。:)
顺便说一句,我正在使用:
Spring Security Core 1.2.4
Grails 2.0.0.RC1

4

3 回答 3

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>

在 BuildConfig 中,groovy:

runtime ":webxml:1.4.1"

这用 Grails 2.2.0 为我解决了这个问题。

于 2013-02-24T13:16:03.310 回答
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

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

于 2012-01-25T11:31:53.567 回答
1

尝试在 web.xml 文件中注册一个 RequestContextListener 监听器。

文件:web.xml

<web-app>
   ...
   <listener>
    <listener-class>
        org.springframework.web.context.request.RequestContextListener
    </listener-class>
   </listener>
</web-app>
于 2014-06-23T06:21:26.463 回答