Grails 应用程序中的 shiro 配置错误

发布于 2024-08-22 08:32:15 字数 711 浏览 6 评论 0原文

我使用 Apache Shiro 作为我的应用程序的认证框架。我正在关注 http://www.grails.org/plugin/shiro 上的参考 我的应用程序抛出异常:

调用代码无法访问 SecurityManager,无论是绑定到 org.apache.shiro.util.ThreadContext 还是作为 vm 静态单例。这是无效的应用程序配置。

java.lang.IllegalStateException:调用代码无法访问 SecurityManager,无论是绑定到 org.apache.shiro.util.ThreadContext 还是作为 vm 静态单例。这是无效的应用程序配置。 在 org.apache.shiro.SecurityUtils.getSecurityManager(SecurityUtils.java:115) 在 org.apache.shiro.SecurityUtils.getSubject(SecurityUtils.java:57) 在br.netsoft.ShiroDbRealmTests.testAutenticarComDadosCorretos(ShiroDbRealmTests.groovy:58) 在 junit.framework.Test$run.call(来源不明)

我能做什么?

i'm using the Apache Shiro as the framework for athetication of my application. I was following the reference at http://www.grails.org/plugin/shiro
and my application throws the exception:

No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton. This is an invalid application configuration.

java.lang.IllegalStateException: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton. This is an invalid application configuration.
at org.apache.shiro.SecurityUtils.getSecurityManager(SecurityUtils.java:115)
at org.apache.shiro.SecurityUtils.getSubject(SecurityUtils.java:57)
at br.netsoft.ShiroDbRealmTests.testAutenticarComDadosCorretos(ShiroDbRealmTests.groovy:58)
at junit.framework.Test$run.call(Unknown Source)

What i can do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

似狗非友 2024-08-29 08:32:15

这似乎是一个已知问题 - 请参阅 http://jira.codehaus.org/browse/GRAILSPLUGINS -1980,那里有一些建议的解决方法。另外,此帖子揭示了一些潜在原因。

This seems to be a known issue - see http://jira.codehaus.org/browse/GRAILSPLUGINS-1980, there are a few suggested workarounds there. Also, this thread sheds some light on potential cause.

酒与心事 2024-08-29 08:32:15

我在 grails 应用程序的单元测试框架中遇到了这个异常。
我在 setUp 方法中初始化了安全服务并测试测试框架,不再出现此异常

@Before
void setUP(){
 new org.apache.shiro.grails.ShiroSecurityService()
}

I was getting this exception in unit test framework for grails app.
I initialized the security service in setUp method and test test-framework no more getting this exception

@Before
void setUP(){
 new org.apache.shiro.grails.ShiroSecurityService()
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文