NutzCN Logo
问答 定时任务 调用nutz的QuartzManager接口中add方法报错
发布于 521天前 作者 qq_a58609e3 392 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

请问在使用定时任务时,调用nutz的QuartzManager接口中add方法报错,违反完整性约束条件:

Caused by: org.quartz.JobPersistenceException: Couldn't store trigger '78b7937d917b42299fff6f652c0c8b08.78b7937d917b42299fff6f652c0c8b08' for '78b7937d917b42299fff6f652c0c8b08.78b7937d917b42299fff6f652c0c8b08' job:ORA-02291: 违反完整约束条件 (NUTZBOOK.SYS_C0024554) - 未找到父项关键字
 [See nested exception: java.sql.SQLIntegrityConstraintViolationException: ORA-02291: 违反完整约束条件 (NUTZBOOK.SYS_C0024554) - 未找到父项关键字
]
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeTrigger(JobStoreSupport.java:1223)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport$8.executeVoid(JobStoreSupport.java:1332)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport$VoidTransactionCallback.execute(JobStoreSupport.java:3719)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport$VoidTransactionCallback.execute(JobStoreSupport.java:3717)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3803)
	at org.quartz.impl.jdbcjobstore.JobStoreTX.executeInLock(JobStoreTX.java:93)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeJobsAndTriggers(JobStoreSupport.java:1323)
	at org.quartz.core.QuartzScheduler.scheduleJobs(QuartzScheduler.java:1056)
	at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:1066)
	at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:286)
	at org.nutz.integration.quartz.QuartzManagerImpl.add(QuartzManagerImpl.java:136)
	... 23 more
Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-02291: 违反完整约束条件 (NUTZBOOK.SYS_C0024554) - 未找到父项关键字

	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
	at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
	at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
	at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
	at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
	at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
	at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1044)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
	at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3584)
	at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3665)
	at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1352)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:2723)
	at com.alibaba.druid.filter.FilterAdapter.preparedStatement_executeUpdate(FilterAdapter.java:1069)
	at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeUpdate(FilterEventAdapter.java:491)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:2721)
	at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeUpdate(PreparedStatementProxyImpl.java:158)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeUpdate(DruidPooledPreparedStatement.java:253)
	at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.insertTrigger(StdJDBCDelegate.java:1093)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeTrigger(JobStoreSupport.java:1220)
	... 33 more
10 回复

报错信息很明显了吧,重名了

貌似也不对, 调用代码怎么写的?

try {
                QuartzJob qj = new QuartzJob();
                qj.setJobName(sysTask.getId());
                qj.setJobGroup(sysTask.getId());
                qj.setClassName(sysTask.getJobClass());
                qj.setCron(sysTask.getCron());
                qj.setComment(sysTask.getNote());
                qj.setDataMap(sysTask.getData());
                quartzManager.add(qj);
            } catch (Exception e) {
                log.error(e.getMessage());
            }

会不会cron是null?

cron是有值的,我改成调用这个add方法也是报那个错误

quartzManager.add("测试任务", sysTask.getId(), "*/5 * * * * ?", TestJob.class);

quartz.properties贴来看看

#==============================================================    
#Configure Main Scheduler Properties    
#==============================================================     
org.quartz.scheduler.instanceName = defaultScheduler
org.quartz.scheduler.instanceId = AUTO

#==============================================================    
#Configure JobStore     isClustered=ÆôÓü¯ÈºÄ£Ê½
#==============================================================   
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.dataSource=myDS
org.quartz.jobStore.tablePrefix = SYS_QRTZ_
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000
org.quartz.jobStore.maxMisfiresToHandleAtATime = 120
org.quartz.jobStore.misfireThreshold = 120000
org.quartz.jobStore.txIsolationLevelSerializable = false

#==============================================================    
#Configure ThreadPool    
#==============================================================   
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 2
org.quartz.threadPool.threadPriority = 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true

#==============================================================  
#Skip Check Update  
#update:true  
#not update:false  
#==============================================================  
org.quartz.scheduler.skipUpdateCheck = true

#============================================================================     
# Configure Plugins      
#============================================================================        
org.quartz.plugin.triggHistory.class = org.quartz.plugins.history.LoggingJobHistoryPlugin
org.quartz.plugin.shutdownhook.class = org.quartz.plugins.management.ShutdownHookPlugin
org.quartz.plugin.shutdownhook.cleanShutdown = true
#============================================================================
# NutDao dataSource
#============================================================================
org.quartz.dataSource.myDS.connectionProvider.class = org.nutz.integration.quartz.NutConnectionProvider

http://www.quartz-scheduler.org/documentation/quartz-2.x/configuration/ConfigJobStoreTX

org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
// 改成
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.oracle.OracleDelegate

改成oracle也不行。我直接把数据库表里那个外键约束去掉了。。不报错了,也能定时启动了,暂时还没看出来有什么影响,就是不知道这么做会不会有别的影响

哪个表的哪个外键??

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