Estou com esta exception:
Acontece quando tento acesso algum recurso @Secured
SEVERE: Servlet.service() for servlet [default] in context with path [/Riddler] threw exception [net.vidageek.mirror.exception.ReflectionProviderException: Could not invoke method index] with root cause
org.apache.shiro.UnavailableSecurityManagerException: 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:123)
at org.apache.shiro.subject.Subject$Builder.<init>(Subject.java:627)
at org.apache.shiro.SecurityUtils.getSubject(SecurityUtils.java:56)
at org.apache.shiro.aop.AnnotationHandler.getSubject(AnnotationHandler.java:57)
at org.apache.shiro.authz.aop.GuestAnnotationHandler.assertAuthorized(GuestAnnotationHandler.java:60)
at org.apache.shiro.authz.aop.AuthorizingAnnotationMethodInterceptor.assertAuthorized(AuthorizingAnnotationMethodInterceptor.java:84)
at org.apache.shiro.authz.aop.AnnotationsAuthorizingMethodInterceptor.assertAuthorized(AnnotationsAuthorizingMethodInterceptor.java:100)
at br.com.caelum.vraptor.security.interceptor.SecurityInterceptor.check(SecurityInterceptor.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
Segui o tutorial do vraptor-shiro bem a risca e não esquece deste cara:
@Controller
public class AuthController implements AuthorizationRestrictionListener {
@Inject
private Result result;
@Inject
private Subject currentUser;
@Override
public void onAuthorizationRestriction(AuthorizationException e) {
result.include("error", e.toString());
if (currentUser.isAuthenticated())
result.redirectTo(RootController.class).index();
else
result.redirectTo(LoginController.class).index();
}
}
Na verdade esta exception é bem bizarra pq estava funcionando antes… Ai eu mudei algumas coisas… parei o servidor, subi de novo… e esta funcionando! Trabalhei em coisas que nao tem nada a ver com o Shiro… muito estranho. Bom, eis um exemplo de um controller que ao acessar a pagina da exception:
@Controller
@Secured
public class LoginController {
...
@RequiresGuest
@Get("/entrar")
public void index() {
}