Error in strong configuration in Grails application

I use Apache Shiro as the basis for testing my application. I followed the link http://www.grails.org/plugin/shiro and my application throws an exception:

There is no SecurityManager available for the calling code, either associated with org.apache.shiro.util.ThreadContext, or as a static singleton vm. This is the wrong application configuration.

java.lang.IllegalStateException: no SecurityManager available for the calling code, either associated with org.apache.shiro.util.ThreadContext, or as a static singleton vm. This is the wrong application configuration. at org.apache.shiro.SecurityUtils.getSecurityManager (SecurityUtils.java:115) at org.apache.shiro.SecurityUtils.getSubject (SecurityUtils.java:57) at br.netsoft.ShiroDbRealmTests.testAutenticarComDadosCorretal.giroroovalovroiro (shiro) junit.framework.Test $ run.call (Unknown source)

What can I do?

+4
source share
2 answers

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

+1
source

I got this exception as part of a unit test for a grails application. I initialized the security service in the setUp method and test environment without receiving this exception

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

Source: https://habr.com/ru/post/1301368/


All Articles