title: Failed creating tables using spring boot quartz
body: <p>I am using JDBCjobstore to save the scheduler details.</p>
  <p>Here is the configuration class and quartz properties which I am using.</p>
  <h1>Quartz.properties</h1>
  <pre><code>org.quartz.scheduler.instanceName=spring-boot-quartz-demo
  org.quartz.scheduler.instanceId=AUTO
  org.quartz.threadPool.threadCount=5
  org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
  org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
  org.quartz.jobStore.useProperties=true
  org.quartz.jobStore.misfireThreshold=60000
  org.quartz.jobStore.tablePrefix=qrtz_
  
  org.quartz.jobStore.isClustered=true
  org.quartz.jobStore.clusterCheckinInterval=20000
  </code></pre>
  <h1>Configuration class:</h1>
  <pre><code>@Configuration
  public class SchedulerConfiguration {
      @Autowired
      DataSource dataSource;
  
  public class AutowireCapableBeanJobFactory extends SpringBeanJobFactory {
  
      private final AutowireCapableBeanFactory beanFactory;
  
      @Autowired
      public AutowireCapableBeanJobFactory(AutowireCapableBeanFactory beanFactory) {
          Assert.notNull(beanFactory, &quot;Bean factory must not be null&quot;);
          this.beanFactory = beanFactory;
      }
  
      @Override
      protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
          Object jobInstance = super.createJobInstance(bundle);
          this.beanFactory.autowireBean(jobInstance);
          this.beanFactory.initializeBean(jobInstance, null);
          return jobInstance;
      }
  }
  
  @Bean
  public SchedulerFactoryBean schedulerFactory(ApplicationContext applicationContext) {
      SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
      schedulerFactoryBean.setOverwriteExistingJobs(true);
      schedulerFactoryBean.setDataSource(dataSource);
      schedulerFactoryBean.setConfigLocation(new ClassPathResource(&quot;/quartz.properties&quot;));
      schedulerFactoryBean.setJobFactory(
              new AutowireCapableBeanJobFactory(applicationContext.getAutowireCapableBeanFactory()));
      return schedulerFactoryBean;
  }
  
  @Bean
  public Scheduler scheduler(ApplicationContext applicationContext) throws SchedulerException {
      Scheduler scheduler = schedulerFactory(applicationContext).getScheduler();
      scheduler.start();
      return scheduler;
  }
  </code></pre>
  <p>}</p>
  <p>I am getting the following exception when I am trying to run the application</p>
  <pre><code>    Position: 15
      
      org.quartz.JobPersistenceException: Failure identifying failed instances when checking-in: ERROR: relation &quot;qrtz_scheduler_state&quot; does not exist
        Position: 15
                      at org.quartz.impl.jdbcjobstore.JobStoreSupport.findFailedInstances(JobStoreSupport.java:3405) ~[quartz-2.3.0.jar:na]
                      at org.quartz.impl.jdbcjobstore.JobStoreSupport.clusterCheckIn(JobStoreSupport.java:3455) ~[quartz-2.3.0.jar:na]
                      at org.quartz.impl.jdbcjobstore.JobStoreSupport.doCheckin(JobStoreSupport.java:3315) ~[quartz-2.3.0.jar:na]
                      at org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.manage(JobStoreSupport.java:3920) [quartz-2.3.0.jar:na]
                      at org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.run(JobStoreSupport.java:3957) [quartz-2.3.0.jar:na]
      Caused by: org.postgresql.util.PSQLException: ERROR: relation &quot;qrtz_scheduler_state&quot; does not exist
        Position: 15
                      at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:106) ~[postgresql-42.2.5.jar:42.2.5]
                      at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52) ~[HikariCP-3.2.0.jar:na]
                      at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java) ~[HikariCP-3.2.0.jar:na]
                      at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectSchedulerStateRecords(StdJDBCDelegate.java:2994) ~[quartz-2.3.0.jar:na]
                      at org.quartz.impl.jdbcjobstore.JobStoreSupport.findFailedInstances(JobStoreSupport.java:3369) ~[quartz-2.3.0.jar:na]
                      ... 4 common frames omitted
      
      2019-03-28 09:49:03.539 ERROR 15320 --- [_MisfireHandler] o.s.s.quartz.LocalDataSourceJobStore     : MisfireHandler: Error handling misfires: Database error recovering from misfires.
      
      org.quartz.JobPersistenceException: Database error recovering from misfires.
                      at org.quartz.impl.jdbcjobstore.JobStoreSupport.doRecoverMisfires(JobStoreSupport.java:3259) ~[quartz-2.3.0.jar:na]
                      at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.manage(JobStoreSupport.java:3997) [quartz-2.3.0.jar:na]
                      at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.run(JobStoreSupport.java:4018) [quartz-2.3.0.jar:na]
      Caused by: org.postgresql.util.PSQLException: ERROR: relation &quot;qrtz_triggers&quot; does not exist
        Position: 33
                      at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143) ~[postgresql-42.2.5.jar:42.2.5]
                      at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:106) ~[postgresql-42.2.5.jar:42.2.5]
                      at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52) ~[HikariCP-3.2.0.jar:na]
  Caused by: org.postgresql.util.PSQLException: ERROR: relation &quot;qrtz_triggers&quot; does not exist
    Position: 33
                  at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) ~[postgresql-42.2.5.jar:42.2.5]
                  at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) ~[postgresql-42.2.5.jar:42.2.5]
                  at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) ~[postgresql-42.2.5.jar:42.2.5]
                  at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.5.jar:42.2.5]
                  at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.5.jar:42.2.5]
                  at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143) ~[postgresql-42.2.5.jar:42.2.5]
                  at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:106) ~[postgresql-42.2.5.jar:42.2.5]
                  at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52) ~[HikariCP-3.2.0.jar:na]
                  at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java) ~[HikariCP-3.2.0.jar:na]
                  at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.countMisfiredTriggersInState(StdJDBCDelegate.java:393) ~[quartz-2.3.0.jar:na]
                  at org.quartz.impl.jdbcjobstore.JobStoreSupport.doRecoverMisfires(JobStoreSupport.java:3238) ~[quartz-2.3.0.jar:na]
                  ... 2 common frames omitted
  
  2019-03-28 09:49:09.668 ERROR 15320 --- [SchedulerThread] org.quartz.core.ErrorLogger              : An error occurred while scanning for the next triggers to fire.
  
  org.quartz.JobPersistenceException: Couldn't acquire next trigger: ERROR: relation &quot;qrtz_triggers&quot; does not exist
    Position: 67
                  at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2910) ~[quartz-2.3.0.jar:na]
                  at org.quartz.impl.jdbcjobstore.JobStoreSupport$41.execute(JobStoreSupport.java:2805) ~[quartz-2.3.0.jar:na]
                  at org.quartz.impl.jdbcjobstore.JobStoreSupport$41.execute(JobStoreSupport.java:2803) ~[quartz-2.3.0.jar:na]
                  at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3849) ~[quartz-2.3.0.jar:na]
                  at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2802) ~[quartz-2.3.0.jar:na]
                  at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:287) ~[quartz-2.3.0.jar:na]
  </code></pre>
  <p>However there is no issue if I create the tables first and then execute the application</p>