【问题标题】:Grails Error: No thread-bound request found: Are you referring to request attributes... After installing Spring Security CoreGrails 错误:未找到线程绑定请求:您指的是请求属性...安装 Spring Security Core 后
【发布时间】:2011-12-22 07:59:25
【问题描述】:


我刚刚创建了一个新的 grails 应用程序,
一切都很好,直到我决定
安装 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 安全核心 1.2.4
Grails 2.0.0.RC1

【问题讨论】:

  • URI /test1/ 命中了什么控制器?它正在采取什么行动?您可以从控制器发布的任何代码都会有所帮助,因为它可能是控制器中的某些内容或不在事务会话中的服务。
  • 您好,我刚刚搭建了所有控制器的脚手架,除了 Spring Security Core 自身生成的控制器。 /test1/ 是我的应用程序的名称。 :)
  • 我刚刚尝试创建一个项目,添加一个域类,在该域上生成所有内容,安装 spring-security-core,运行 s2-quickstart,它工作正常。你试过 grails clean 吗?
  • 是的... Grails clean 实际上是我做的第一件事,但没有运气.. 我应您的要求再次尝试,但还是一样.. 嗯.. 一定有什么地方出了问题,我所有的其他应用程序似乎都运行顺利。抱歉,我对 servlet 和其他东西不是很熟悉。 :(
  • 我还没有解决这个问题..但是环顾一下grails.jira...似乎有些人和我有同样的问题..jira.grails.org/browse/GPSPRINGSECURITYCORE-98

标签: grails spring-security illegalstateexception


【解决方案1】:

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

文件:web.xml

<web-app>
   ...
   <listener>
    <listener-class>
        org.springframework.web.context.request.RequestContextListener
    </listener-class>
   </listener>
</web-app>

【讨论】:

    【解决方案2】:

    如果您使用的是 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 的问题。

    【讨论】:

    • 这在 Grails 2.2.3、spring-security-core 1.2.7.3 中为我修复了,谢谢!!
    • 修改 BuildConfig.groovy 对我不起作用,但将“plugins.webxml=1.4.1”添加到 application.properties 解决了它。 (我正在使用 ggts)
    【解决方案3】:

    如果您使用的是旧版本的 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 由황현정建议。

    【讨论】:

    • 非常好,就像一个魅力,但是来自 grails 告诉我运行该命令的 s2-quickstart 消息是什么?
    猜你喜欢
    • 2016-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-02
    • 1970-01-01
    • 1970-01-01
    • 2023-01-18
    • 1970-01-01
    相关资源
    最近更新 更多