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.
操作日志切面发生这个问题导致无法保存操作日志;本地测试接口可以保存日志,但是上服务器就不行;
具体原因没弄明白,求教;
个人理解感觉像是因为我的操作日志切面是多线程的,shiro默认只绑定到一个线程上,我在线程里面又用了shiro的操作,所以导致这种情况发生;在本地测试接口没问题是因为我在本地测试只是单用户登录的操作,而上到服务器时是多用户的,所以就导致了问题的发生;有看到的麻烦解答一下是不是这个原因;谢谢!
目前的解决办法是
private static DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
@AfterReturning(value = "within(com.etian.web..*) && @annotation(operationLog)", returning = "object")
public void insertLog(JoinPoint joinPoint, OperationLog operationLog, Object object) throws Throwable {
ThreadContext.bind(manager);
Session session = SecurityUtils.getSubject().getSession();
String loginIp = (String) session.getAttribute("loginIp");
ThreadPoolTask task = new ThreadPoolTask(joinPoint,operationLog,object,loginIp);
rejectWebThreadPool.execute(task);
}
手动绑定了一下;照目前看是没有再出现过保存不了日志的问题