【问题标题】:Grails No thread-bound request found error?Grails No thread-bound request found 错误?
【发布时间】:2021-11-13 08:58:46
【问题描述】:

按照 spring securty 和 saml 插件教程,我创建了一个简单的应用程序。

这是我创建简单的 hello world 应用所遵循的教程的链接。

http://grails-plugins.github.io/grails-spring-security-core/2.0.x/guide/tutorials.html

https://www.wave-access.com/public_en/blog/2014/june/23/how-we-configured-saml-20-on-grails.aspx

我终于可以配置 saml 插件了。

应用程序现在运行但抛出 500 运行时错误,如下所示。

我环顾了一段时间,没有找到任何有用的解决方案。该应用程序和插件都很旧,因为我必须使用 grails 2.2。

我正在使用 grails 2.2。

感谢任何有关导致此未发现线程绑定请求异常的原因的见解。

我已在 github 上发布代码供您参考

https://github.com/learningcscience/saml

谢谢!

|Loading Grails 2.2.0
No mavenInfo file found.
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
....
|Compiling 1 source files
.............
|Running Grails application

Configuring Spring Security Core ...
... finished configuring Spring Security Core

Configuring Spring Security SAML ...
Registering metadata key: ping and value: security/idp-local.xml
...finished configuring Spring Security SAML
|Server running. Browse to http://localhost:8080/bookstore
Error |
2021-09-19 12:47:23,330 [http-bio-8080-exec-3] ERROR [/bookstore].[gsp]  - Servlet.service() for servlet [gsp] in context with path [/bookstore] threw exception
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.
    Line | Method
->> 1152 | runWorker in java.util.concurrent.ThreadPoolExecutor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    622 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    748 | run . . . in java.lang.Thread

Error |
2021-09-19 12:47:24,146 [http-bio-8080-exec-2] ERROR [/bookstore].[default]  - Servlet.service() for servlet [default] in context with path [/bookstore] threw exception
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.
    Line | Method
->> 1152 | runWorker in java.util.concurrent.ThreadPoolExecutor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    622 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    748 | run . . . in java.lang.Thread

【问题讨论】:

    标签: grails spring-security saml grails-2.2


    【解决方案1】:

    快速查看您的配置后,您似乎尚未完成 SAML on GRAILS 教程的第 3 步:

    3.密钥管理器设置

    • [....]
    • 下载 sp.xml 并将其保存在 grails-app/conf/security/文件夹中。将我们在 OpenAM 服务器配置中生成的 ipd.xml 复制到同一文件夹中。在 Config.groovy 中添加 sp 和 idp 设置:
    grails.plugins.springsecurity.saml.metadata.sp.file = 'security/sp.xml'
            grails.plugins.springsecurity.saml.metadata.providers = [idp: 'security/idp.xml']
            grails.plugins.springsecurity.saml.metadata.defaultIdp = 'idp'
            grails.plugins.springsecurity.saml.metadata.sp.defaults = [
                local: true,
                alias: 'localSp',
                securityProfile: 'metaiop',
                signingKey: 'apollo',
                encryptionKey: 'apollo',
                requireArtifactResolveSigned: true,
                requireLogoutRequestSigned: true,
                requireLogoutResponseSigned: true
            ]
    

    请注意,教程中说“复制 ipd.xml”,这可能是一个错字。应该改为idp.xml 吗?

    【讨论】:

    • 顺便问一下,您是否有限制使用较新的 GRAILS 版本? (2.2.x 现在有点过时了)。不要误会我的意思,我自己还有几个 GRAILS 2.x 项目。只是想知道为什么不至少使用最新版本的 2.x 系列(即 GRAILS 2.5.6)
    • 谢谢 rchfox。今天我试试你的建议。由于空间和资源的限制,现在我们被 grails 2.2 困住了。也没有时间进行升级,这需要很长时间。谢谢!很快就会更新。
    • 好的,我刚刚添加了缺少的配置,但它仍然在抛出 2021-09-20 10:40:00,910 [http-bio-8080-exec-3] ERROR [/bookstore].[gsp] - servlet [gsp] 的 Servlet.service() 在路径 [/bookstore] 的上下文中抛出异常消息:未找到线程绑定请求:您是指实际 Web 请求之外的请求属性,还是处理外部请求最初接收线程?
    • 顺便说一句,我故意留下缺少的步骤,因为在此之前它说运行应用程序。有一个 UI 可用作元数据控制器 localhost:8080/myApp/metadata)。而且网址无效。
    猜你喜欢
    • 1970-01-01
    • 2012-01-21
    • 1970-01-01
    • 2013-04-05
    • 2013-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多