관리 메뉴

너와 나의 스토리

Spring Quartz Scheduler H2 table 생성 (에러 해결) 본문

개발/Spring Boot

Spring Quartz Scheduler H2 table 생성 (에러 해결)

노는게제일좋아! 2022. 11. 30. 14:55
반응형

 

에러 메시지:

Failed to start bean 'schedulerFactoryBean'; nested exception is org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Table "QRTZ_LOCKS" not found; SQL statement:
SELECT * FROM QRTZ_LOCKS WHERE SCHED_NAME = 'schedulerFactoryBean' AND LOCK_NAME = ? FOR UPDATE [42102-200] [See nested exception: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "QRTZ_LOCKS" not found; SQL statement:

...

caused by: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Table "QRTZ_LOCKS" not found; SQL statement:

원인:

  • h2에 Quartz Schedular가 사용하는 테이블이 자동으로 생성되지 않아서 생기는 문제.

 

해결 방법:

  • 스케줄러에서 사용하는 table을 생성할 sql script 작성
  • SQL Script 설정 
spring:
  datasource:
    schema: classpath:quartz-mysql.sql

 

 

에러 메시지:

org.quartz.JobPersistenceException: Couldn't store job: Value too long for column "IS_DURABLE VARCHAR(1)": "'FALSE' (5)"; SQL statement:
INSERT INTO QRTZ_JOB_DETAILS (SCHED_NAME, JOB_NAME, JOB_GROUP, DESCRIPTION, JOB_CLASS_NAME, IS_DURABLE, IS_NONCONCURRENT, IS_UPDATE_DATA, REQUESTS_RECOVERY, JOB_DATA)  VALUES('schedulerFactoryBean', ?, ?, ?, ?, ?, ?, ?, ?, ?) [22001-200] [See nested exception: org.h2.jdbc.JdbcSQLDataException: Value too long for column "IS_DURABLE VARCHAR(1)": "'FALSE' (5)"; SQL statement:
INSERT INTO QRTZ_JOB_DETAILS (SCHED_NAME, JOB_NAME, JOB_GROUP, DESCRIPTION, JOB_CLASS_NAME, IS_DURABLE, IS_NONCONCURRENT, IS_UPDATE_DATA, REQUESTS_RECOVERY, JOB_DATA)  VALUES('schedulerFactoryBean', ?, ?, ?, ?, ?, ?, ?, ?, ?) [22001-200]]

원인:

  • 현재 H2 버전에서 Boolean에서 VARCHAR (1)로 자동 전환이 되지 않아서 

 

해결 방법:

  • sql 문에서 'VARCAHR (1)'를 BOOLEAN으로 변경 

 

반응형
Comments