【问题标题】:Error in shiro configuration in a Grails-appGrails 应用程序中的 shiro 配置错误
【发布时间】:2011-01-17 02:23:19
【问题描述】:

我正在使用 Apache Shiro 作为我的应用程序的 athetication 框架。我正在关注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(Unknown Source)

我能做什么?

【问题讨论】:

  • 您只是在运行测试时遇到问题吗?我也在使用 shiro,我也有这个问题 - 但仅限于测试时。你找到解决办法了吗?

标签: grails grails-plugin shiro


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2012-01-27
      • 2016-04-17
      • 2011-01-15
      • 1970-01-01
      • 2014-02-22
      • 1970-01-01
      • 2019-05-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多