NutzCN Logo
问答 定时任务更新实体报shiro错误
发布于 2450天前 作者 qq_c6be67f9 3942 次浏览 复制 上一个帖子 下一个帖子
标签:
[ERROR] 16:00:20.293 org.quartz.core.JobRunShell.run(JobRunShell.java:211) - Job DEFAULT.com.panport.raiis.fids.util.MonitorDeviceScheduler threw an unhandled Exception: 
org.nutz.dao.DaoException: 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.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:245)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:257)
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:55)
	at org.nutz.dao.impl.NutDao.update(NutDao.java:224)
	at com.panport.raiis.fids.service.impl.DeviceIrregularServiceImpl.checkDevices(DeviceIrregularServiceImpl.java:70)
	at com.panport.raiis.fids.util.MonitorDeviceScheduler.execute(MonitorDeviceScheduler.java:44)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: 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 com.panport.raiis.nutz.util.UpdateDaoInterceptor.filter(UpdateDaoInterceptor.java:56)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
	... 10 more
[ERROR] 16:00:20.297 org.quartz.core.ErrorLogger.schedulerError(QuartzScheduler.java:2425) - Job (DEFAULT.com.panport.raiis.fids.util.MonitorDeviceScheduler threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: org.nutz.dao.DaoException: 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.quartz.core.JobRunShell.run(JobRunShell.java:213)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: org.nutz.dao.DaoException: 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.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:245)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:257)
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:55)
	at org.nutz.dao.impl.NutDao.update(NutDao.java:224)
	at com.panport.raiis.fids.service.impl.DeviceIrregularServiceImpl.checkDevices(DeviceIrregularServiceImpl.java:70)
	at com.panport.raiis.fids.util.MonitorDeviceScheduler.execute(MonitorDeviceScheduler.java:44)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
	... 1 more
Caused by: 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 com.panport.raiis.nutz.util.UpdateDaoInterceptor.filter(UpdateDaoInterceptor.java:56)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
	... 10 more
[DEBUG] 16:00:47.213 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:276) - batch acquisition of 0 triggers

出错的代码是

	dao().update(device);

定时任务代码

@IocBean
public class MonitorDeviceScheduler implements Job {

	
	@Inject protected DeviceIrregularService deviceIrregularService;
	
	Logger log = new Logger(this.getClass());
	
	public static Map<String, Date> dateMap = new HashMap<>();

    @Inject protected Dao dao;

	@Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
    	log.error("=================定时任务开始:"+System.currentTimeMillis()+"====================");
    	deviceIrregularService.checkDevices();
    	log.error("=================定时任务结束:"+System.currentTimeMillis()+"====================");
    }
5 回复

定时任务可以执行,就是在更新实体的时候回报这个错误

UpdateDaoInterceptor这个类里面防御一下

哦哦谢谢文达,我用个try catch弄好了,顺便在请教一下,在mainmodule里面的@IocBy添加定时任务相关的

"*quartz", // 集成quartz的ioc配置
"*org.nutz.integration.quartz.QuartzIocLoader"

这两个有啥区别吗?

前者是后者的简写,规则可以看ComboIocLoader的源码

好的谢谢!谢谢谢谢!谢谢

添加回复
请先登陆
回到顶部