我正在尝试测试quartz调度器是否已完成单元测试。我使用内存数据库并为quartz创建所有必要的表。当我运行schedulerconfigtest.java时,由于 user lacks privilege or object not found: QRTZ_JOB_DETAILS
. 我知道它确实创建了表,所以.sql文件应该是有效的。
下面是我的设置:schedulerconfig.java
@Configuration
@Import({ DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class })
public class SchedulerConfig {
private static final String JOB_DESC = "Job to update email blacklist";
private static final String GROUP = "EmailBlacklistScheduler";
@Value("${scheduler.emailBlacklist.cron}")
private String emailBlacklistTrigger;
@Value("${scheduler.name}")
private String schedulerName;
@Bean
public ApplicationContextHelper applicationContextHelper() {
return new ApplicationContextHelper();
}
@Bean
public SchedulerFactoryBean scheduler(final DataSource dataSource,
final DataSourceTransactionManager transactionManager) {
SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
scheduler.setSchedulerName(this.schedulerName);
scheduler.setOverwriteExistingJobs(true);
scheduler.setDataSource(dataSource);
scheduler.setTransactionManager(transactionManager);
scheduler.setQuartzProperties(quartzProperties());
scheduler.setTriggers(schedulerTriggers());
scheduler.setJobDetails(schedulerJobs());
return scheduler;
}
@Bean
@ConfigurationProperties("scheduler")
public Properties quartzProperties() {
return new Properties();
}
@Bean
public Trigger[] schedulerTriggers() {
return new Trigger[] { schedulerUpdaterTrigger().getObject() };
}
@Bean
public JobDetail[] schedulerJobs() {
return new JobDetail[] { schedulerUpdaterJob().getObject() };
}
@Bean
public JobDetailFactoryBean schedulerUpdaterJob() {
JobDetailFactoryBean jobDetailFactoryBean = new JobDetailFactoryBean();
jobDetailFactoryBean.setJobClass(SmtpScheduler.class);
jobDetailFactoryBean.setName(SmtpScheduler.class.getSimpleName());
jobDetailFactoryBean.setDescription(JOB_DESC);
jobDetailFactoryBean.setGroup(GROUP);
jobDetailFactoryBean.setDurability(true);
return jobDetailFactoryBean;
}
@Bean
public CronTriggerFactoryBean schedulerUpdaterTrigger() {
CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
cronTriggerFactoryBean.setJobDetail(schedulerUpdaterJob().getObject());
cronTriggerFactoryBean.setCronExpression(emailBlacklistTrigger);
return cronTriggerFactoryBean;
}
}
schedulerconfigtest.java文件
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = { SchedulerConfig.class })
@TestPropertySource("classpath:application.properties")
public class SchedulerConfigTest {
@Autowired
private ApplicationContextHelper applicationContextHelper;
@Autowired
private SchedulerFactoryBean scheduler;
@Autowired
private Trigger[] schedulerTriggers;
@Autowired
private JobDetail[] schedulerJobs;
@BeforeClass
public static void before() {
new EmbeddedDatabaseBuilder()
.setType(EmbeddedDatabaseType.HSQL)
.addScript("create-scheduler-tables.sql")
.build();
}
@Test
public void applicationContextHelper() {
assertNotNull(applicationContextHelper);
}
@Test
public void scheduler() {
assertNotNull(scheduler);
}
@Test
public void schedulerTriggers() {
assertNotNull(schedulerTriggers);
}
@Test
public void schedulerJobs() {
assertNotNull(schedulerJobs);
}
}
创建-scheduler-tables.sql
SET DATABASE SQL SYNTAX MSS TRUE;
DROP TABLE QRTZ_LOCKS
IF EXISTS ;
DROP TABLE qrtz_scheduler_state
IF EXISTS ;
DROP TABLE QRTZ_FIRED_TRIGGERS
IF EXISTS ;
DROP TABLE QRTZ_PAUSED_TRIGGER_GRPS
IF EXISTS ;
DROP TABLE QRTZ_CALENDARS
IF EXISTS ;
DROP TABLE QRTZ_BLOB_TRIGGERS
IF EXISTS ;
DROP TABLE QRTZ_CRON_TRIGGERS
IF EXISTS ;
DROP TABLE qrtz_simple_triggers
IF EXISTS ;
DROP TABLE qrtz_simprop_triggers
IF EXISTS ;
DROP TABLE qrtz_triggers
IF EXISTS ;
DROP TABLE QRTZ_JOB_DETAILS
IF EXISTS ;
CREATE TABLE QRTZ_JOB_DETAILS
(
SCHED_NAME VARCHAR(120) NOT NULL,
JOB_NAME VARCHAR(200) NOT NULL,
JOB_GROUP VARCHAR(200) NOT NULL,
DESCRIPTION VARCHAR(250) NULL,
JOB_CLASS_NAME VARCHAR(250) NOT NULL,
IS_DURABLE BOOLEAN NOT NULL,
IS_NONCONCURRENT BOOLEAN NOT NULL,
IS_UPDATE_DATA BOOLEAN NOT NULL,
REQUESTS_RECOVERY BOOLEAN NOT NULL,
JOB_DATA BLOB NULL,
PRIMARY KEY(SCHED_NAME, JOB_NAME, JOB_GROUP)
);
CREATE TABLE qrtz_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
JOB_NAME VARCHAR(200) NOT NULL,
JOB_GROUP VARCHAR(200) NOT NULL,
DESCRIPTION VARCHAR(250) NULL,
NEXT_FIRE_TIME NUMERIC(13)NULL,
PREV_FIRE_TIME NUMERIC(13)NULL,
PRIORITY INTEGER NULL,
TRIGGER_STATE VARCHAR(16)NOT NULL,
TRIGGER_TYPE VARCHAR(8)NOT NULL,
START_TIME NUMERIC(13)NOT NULL,
END_TIME NUMERIC(13)NULL,
CALENDAR_NAME VARCHAR(200)NULL,
MISFIRE_INSTR NUMERIC(2)NULL,
JOB_DATA BLOB NULL,
PRIMARY KEY(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP),
FOREIGN KEY(SCHED_NAME, JOB_NAME, JOB_GROUP)
REFERENCES QRTZ_JOB_DETAILS(SCHED_NAME, JOB_NAME, JOB_GROUP)
);
CREATE TABLE qrtz_simple_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
REPEAT_COUNT NUMERIC(7)NOT NULL,
REPEAT_INTERVAL NUMERIC(12)NOT NULL,
TIMES_TRIGGERED NUMERIC(10)NOT NULL,
PRIMARY KEY(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP),
FOREIGN KEY(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
);
CREATE TABLE qrtz_cron_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
CRON_EXPRESSION VARCHAR(120) NOT NULL,
TIME_ZONE_ID VARCHAR(80),
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
);
CREATE TABLE qrtz_simprop_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
STR_PROP_1 VARCHAR(512) NULL,
STR_PROP_2 VARCHAR(512) NULL,
STR_PROP_3 VARCHAR(512) NULL,
INT_PROP_1 NUMERIC(9)NULL,
INT_PROP_2 NUMERIC(9)NULL,
LONG_PROP_1 NUMERIC(13)NULL,
LONG_PROP_2 NUMERIC(13)NULL,
DEC_PROP_1 NUMERIC(13, 4)NULL,
DEC_PROP_2 NUMERIC(13, 4)NULL,
BOOL_PROP_1 BOOLEAN NULL,
BOOL_PROP_2 BOOLEAN NULL,
PRIMARY KEY(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP),
FOREIGN KEY(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
);
CREATE TABLE qrtz_blob_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
BLOB_DATA BLOB NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
);
CREATE TABLE qrtz_calendars
(
SCHED_NAME VARCHAR(120) NOT NULL,
CALENDAR_NAME VARCHAR(200) NOT NULL,
CALENDAR BLOB NOT NULL,
PRIMARY KEY(SCHED_NAME, CALENDAR_NAME)
);
CREATE TABLE qrtz_paused_trigger_grps
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
PRIMARY KEY(SCHED_NAME, TRIGGER_GROUP)
);
CREATE TABLE qrtz_fired_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
ENTRY_ID VARCHAR(95) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
INSTANCE_NAME VARCHAR(200) NOT NULL,
FIRED_TIME NUMERIC(13)NOT NULL,
SCHED_TIME NUMERIC(13)NOT NULL,
PRIORITY INTEGER NOT NULL,
STATE VARCHAR(16)NOT NULL,
JOB_NAME VARCHAR(200)NULL,
JOB_GROUP VARCHAR(200)NULL,
IS_NONCONCURRENT BOOLEAN NULL,
REQUESTS_RECOVERY BOOLEAN NULL,
PRIMARY KEY(SCHED_NAME, ENTRY_ID)
);
CREATE TABLE qrtz_scheduler_state
(
SCHED_NAME VARCHAR(120) NOT NULL,
INSTANCE_NAME VARCHAR(200) NOT NULL,
LAST_CHECKIN_TIME NUMERIC(13)NOT NULL,
CHECKIN_INTERVAL NUMERIC(13)NOT NULL,
PRIMARY KEY(SCHED_NAME, INSTANCE_NAME)
);
CREATE TABLE qrtz_locks
(
SCHED_NAME VARCHAR(120) NOT NULL,
LOCK_NAME VARCHAR(40) NOT NULL,
PRIMARY KEY(SCHED_NAME, LOCK_NAME)
);
应用程序属性:
# ===================================
# Application Custom properties
# ===================================
smtp.apiKey=apiKey
smtp.url=https://api.smtp2go.com/emails
smtp.username=laura.evans@nuance.com
smtp.limit=5
smtp.bounce.max.tries=5
# ==========================
# Hibernate
# ==========================
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.DefaultNamingStrategy
# Hibernate ddl auto (validate, create, create-drop, update)
spring.jpa.hibernate.ddl-auto=none
# ===============================
# = DATA SOURCE
# Set here configurations for the database connection
# ===============================
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driverClassName=org.hsqldb.jdbc.JDBCDriver
spring.datasource.remove-abandoned=true
spring.datasource.remove-abandoned-timeout=600
spring.datasource.initial-size=2
spring.datasource.max-active=8
spring.datasource.min-idle=0
spring.datasource.max-idle=2
spring.datasource.max-wait=30000
spring.datasource.test-while-idle=true
# ===============================
# Quartz Scheduler
# ===============================
scheduler.name=TestScheduler
scheduler.emailBlacklist.cron=0 0/2 * * * ?
scheduler.org.quartz.scheduler.name=TestScheduler
scheduler.org.quartz.scheduler.instanceId=AUTO
scheduler.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
scheduler.org.quartz.threadPool.threadCount=10
scheduler.org.quartz.threadPool.threadPriority=5
scheduler.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreCMT
scheduler.org.quartz.jobStore.misfireThreshold=60000
scheduler.org.quartz.jobStore.isClustered=true
scheduler.org.quartz.jobStore.clusterCheckinInterval=15000
scheduler.org.quartz.jobStore.tablePrefix=QRTZ_
scheduler.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.HSQLDBDelegate
scheduler.org.quartz.jobStore.useProperties=false
例外
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:244)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scheduler' defined in com.nuance.powershare.email.scheduler.SchedulerConfig: Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't determine job existence (EmailBlacklistScheduler.SmtpScheduler): user lacks privilege or object not found: QRTZ_JOB_DETAILS in statement [SELECT JOB_NAME FROM QRTZ_JOB_DETAILS WHERE SCHED_NAME = 'TestScheduler' AND JOB_NAME = ? AND JOB_GROUP = ?] [See nested exception: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: QRTZ_JOB_DETAILS in statement [SELECT JOB_NAME FROM QRTZ_JOB_DETAILS WHERE SCHED_NAME = 'TestScheduler' AND JOB_NAME = ? AND JOB_GROUP = ?]]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:925)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:923)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:127)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:275)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:243)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
... 26 more
Caused by: org.quartz.JobPersistenceException: Couldn't determine job existence (EmailBlacklistScheduler.SmtpScheduler): user lacks privilege or object not found: QRTZ_JOB_DETAILS in statement [SELECT JOB_NAME FROM QRTZ_JOB_DETAILS WHERE SCHED_NAME = 'TestScheduler' AND JOB_NAME = ? AND JOB_GROUP = ?] [See nested exception: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: QRTZ_JOB_DETAILS in statement [SELECT JOB_NAME FROM QRTZ_JOB_DETAILS WHERE SCHED_NAME = 'TestScheduler' AND JOB_NAME = ? AND JOB_GROUP = ?]]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.jobExists(JobStoreSupport.java:1137)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeJob(JobStoreSupport.java:1109)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$3.executeVoid(JobStoreSupport.java:1095)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$VoidTransactionCallback.execute(JobStoreSupport.java:3780)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$VoidTransactionCallback.execute(JobStoreSupport.java:3778)
at org.quartz.impl.jdbcjobstore.JobStoreCMT.executeInLock(JobStoreCMT.java:245)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeJob(JobStoreSupport.java:1091)
at org.quartz.core.QuartzScheduler.addJob(QuartzScheduler.java:938)
at org.quartz.core.QuartzScheduler.addJob(QuartzScheduler.java:927)
at org.quartz.impl.StdScheduler.addJob(StdScheduler.java:268)
at org.springframework.scheduling.quartz.SchedulerAccessor.addJobToScheduler(SchedulerAccessor.java:284)
at org.springframework.scheduling.quartz.SchedulerAccessor.registerJobsAndTriggers(SchedulerAccessor.java:226)
at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:505)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1847)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784)
... 41 more
Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: QRTZ_JOB_DETAILS in statement [SELECT JOB_NAME FROM QRTZ_JOB_DETAILS WHERE SCHED_NAME = 'TestScheduler' AND JOB_NAME = ? AND JOB_GROUP = ?]
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:337)
at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
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.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.invoke(AttributeRestoringConnectionInvocationHandler.java:73)
at com.sun.proxy.$Proxy37.prepareStatement(Unknown Source)
at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.jobExists(StdJDBCDelegate.java:773)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.jobExists(JobStoreSupport.java:1135)
... 55 more
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: QRTZ_JOB_DETAILS
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ParserDQL.readTableName(Unknown Source)
at org.hsqldb.ParserDQL.readTableOrSubquery(Unknown Source)
at org.hsqldb.ParserDQL.XreadTableReference(Unknown Source)
at org.hsqldb.ParserDQL.XreadFromClause(Unknown Source)
at org.hsqldb.ParserDQL.XreadTableExpression(Unknown Source)
at org.hsqldb.ParserDQL.XreadQuerySpecification(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleTable(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpressionBody(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpression(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 67 more
我发现调度程序在抛出异常之前就关闭了:
13:17:10.351 [main] INFO org.quartz.core.QuartzScheduler - Scheduler TestScheduler_$_bn-jhagen-mac.local1613499430315 shutting down.
13:17:10.351 [main] INFO org.quartz.core.QuartzScheduler - Scheduler TestScheduler_$_bn-jhagen-mac.local1613499430315 paused.
13:17:10.351 [main] DEBUG org.quartz.simpl.SimpleThreadPool - Shutting down threadpool...
13:17:10.821 [TestScheduler_Worker-9] DEBUG org.quartz.simpl.SimpleThreadPool - WorkerThread is shut down.
13:17:10.821 [TestScheduler_Worker-2] DEBUG org.quartz.simpl.SimpleThreadPool - WorkerThread is shut down.
13:17:10.821 [TestScheduler_Worker-5] DEBUG org.quartz.simpl.SimpleThreadPool - WorkerThread is shut down.
13:17:10.828 [TestScheduler_Worker-1] DEBUG org.quartz.simpl.SimpleThreadPool - WorkerThread is shut down.
13:17:10.821 [TestScheduler_Worker-3] DEBUG org.quartz.simpl.SimpleThreadPool - WorkerThread is shut down.
13:17:10.828 [TestScheduler_Worker-8] DEBUG org.quartz.simpl.SimpleThreadPool - WorkerThread is shut down.
13:17:10.821 [TestScheduler_Worker-7] DEBUG org.quartz.simpl.SimpleThreadPool - WorkerThread is shut down.
13:17:10.828 [TestScheduler_Worker-10] DEBUG org.quartz.simpl.SimpleThreadPool - WorkerThread is shut down.
13:17:10.821 [TestScheduler_Worker-4] DEBUG org.quartz.simpl.SimpleThreadPool - WorkerThread is shut down.
13:17:10.821 [TestScheduler_Worker-6] DEBUG org.quartz.simpl.SimpleThreadPool - WorkerThread is shut down.
13:17:10.828 [main] DEBUG org.quartz.simpl.SimpleThreadPool - No executing jobs remaining, all threads stopped.
13:17:10.828 [main] DEBUG org.quartz.simpl.SimpleThreadPool - Shutdown of threadpool complete.
13:17:10.828 [main] DEBUG org.springframework.scheduling.quartz.LocalDataSourceJobStore - JobStore background threads shutdown.
13:17:10.828 [main] INFO org.quartz.core.QuartzScheduler - Scheduler TestScheduler_$_bn-jhagen-mac.local1613499430315 shutdown complete.
13:17:10.829 [main] WARN org.springframework.context.support.GenericApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scheduler' defined in com.nuance.powershare.email.scheduler.SchedulerConfig: Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't determine job existence (EmailBlacklistScheduler.SmtpScheduler): user lacks privilege or object not found: QRTZ_JOB_DETAILS in statement [SELECT JOB_NAME FROM QRTZ_JOB_DETAILS WHERE SCHED_NAME = 'TestScheduler' AND JOB_NAME = ? AND JOB_GROUP = ?] [See nested exception: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: QRTZ_JOB_DETAILS in statement [SELECT JOB_NAME FROM QRTZ_JOB_DETAILS WHERE SCHED_NAME = 'TestScheduler' AND JOB_NAME = ? AND JOB_GROUP = ?]]
13:17:10.829 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
13:17:10.829 [main] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Before shutdown stats (total=10, active=0, idle=10, waiting=0)
13:17:10.830 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.hsqldb.jdbc.JDBCConnection@654d8173: (connection evicted)
13:17:10.830 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.hsqldb.jdbc.JDBCConnection@113cbac4: (connection evicted)
13:17:10.830 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.hsqldb.jdbc.JDBCConnection@1ffb4693: (connection evicted)
13:17:10.830 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.hsqldb.jdbc.JDBCConnection@1bc4d1b4: (connection evicted)
13:17:10.830 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.hsqldb.jdbc.JDBCConnection@5ec64ca8: (connection evicted)
13:17:10.830 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.hsqldb.jdbc.JDBCConnection@2ad8272e: (connection evicted)
13:17:10.831 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.hsqldb.jdbc.JDBCConnection@6f523338: (connection evicted)
13:17:10.831 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.hsqldb.jdbc.JDBCConnection@52a60617: (connection evicted)
13:17:10.831 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.hsqldb.jdbc.JDBCConnection@3ee9b3e7: (connection evicted)
13:17:10.831 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.hsqldb.jdbc.JDBCConnection@55e30243: (connection evicted)
13:17:10.831 [main] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After shutdown stats (total=0, active=0, idle=0, waiting=0)
13:17:10.831 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.
13:17:10.836 [main] ERROR org.springframework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@ba8d91c] to prepare test instance [com.nuance.powershare.email.scheduler.SchedulerConfigTest@46fa7c39]
java.lang.IllegalStateException: Failed to load ApplicationContext
为什么它会关闭scheduler(关闭数据库)?我有另一个项目,是由别人写的,它运行不关闭它。区别在于 13:17:10.350 [main] DEBUG org.springframework.jdbc.support.JdbcTransactionManager - Releasing JDBC Connection [HikariProxyConnection@1674403916 wrapping org.hsqldb.jdbc.JDBCConnection@654d8173] after transaction
,这发生在关闭调度程序之前,其他项目使用datasourcetransactionmanager而不是jdbc。
我试图谷歌和堆栈溢出这个问题,但没有太多的运气。我甚至不知道从哪里开始调查这个问题。
1条答案
按热度按时间fcg9iug31#
我找到了解决办法。我不得不搬家
create-scheduler-tables.sql
至schema.sql
在同一条路上。我还删除了从我的测试和它的工作。我不知道为什么。