4

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?

Lucas
  • 3,059
  • 5
  • 33
  • 48
  • Are you only having the problem when running your tests? I'm using shiro also and I have this problem too - but only when testing. Have you worked out a solution? – Brandon Mar 26 '10 at 10:46

2 Answers2

1

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.

Jean Barmash
  • 4,788
  • 1
  • 32
  • 40
0

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()
}
mukut
  • 130
  • 3
  • 3