关注JEECG发展历程 关注最新动态和版本, 记录JEECG成长点滴 更新日志 - 技术支持 - 招聘英才

JEECG最新版本下载 JEECG智能开发平台 - 显著提高开发效率 常见问题 - 入门视频 - 参与开源团队

商务QQ: 69893005、3102411850 商务热线(5*8小时): 010-64808099 官方邮箱: jeecgos@163.com

查看: 7274|回复: 1

请问定时任务执行保存数据后shiro错误问题怎么解决

[复制链接]
发表于 2019-12-12 17:09:48 | 显示全部楼层 |阅读模式

报错信息如下

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:626)
        at org.apache.shiro.SecurityUtils.getSubject(SecurityUtils.java:56)
        at org.jeecg.config.mybatis.MybatisInterceptor.intercept(MybatisInterceptor.java:140)
        at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
        at com.sun.proxy.$Proxy316.update(Unknown Source)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
        at com.sun.proxy.$Proxy133.update(Unknown Source)
        at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:294)
        at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:63)
        at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:62)
        at com.sun.proxy.$Proxy215.updateById(Unknown Source)
        at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.updateById(ServiceImpl.java:207)
        at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl$$FastClassBySpringCGLIB$$76535273.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684)
        at org.jeecg.modules.mi.service.impl.BookServiceImpl$$EnhancerBySpringCGLIB$$5cca90b9.updateById(<generated>)
        at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl$$FastClassBySpringCGLIB$$76535273.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684)
        at org.jeecg.modules.mi.service.impl.BookServiceImpl$$EnhancerBySpringCGLIB$$b2c7267.updateById(<generated>)

应该定时任务线程无法获取到上下文,请问如何解决,或者有什么折中的办法?
 楼主| 发表于 2019-12-12 20:43:15 | 显示全部楼层
通过修改MybatisInterceptor 拦截器UPDATE部分代码已解决

// 获取登录用户信息
LoginUser sysUser = null;
try{
sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
}catch (Exception e){
sysUser = null;
}
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表