UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound

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);
    }

手动绑定了一下;照目前看是没有再出现过保存不了日志的问题

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值