springspring-batchh2spring-batch-job-monitoring

Table "BATCH_JOB_INSTANCE" not found: org.h2.jdbc.JdbcSQLException


I am trying to run my application using the embedded h2 db.

I get the following error:

Caused by: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]; nested exception is org.h2.jdbc.JdbcSQLException: Table "BATCH_JOB_INSTANCE" not found; SQL statement:
SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ? [42102-197]

I've already tried:

  1. Deleting the h2 repository from the .m2 local folder and re-import and re-install - unsuccessfully.
  2. I also tried configuring the properties file with the following:

spring.datasource.driverClassName=org.h2.Driver

spring.datasource.url=jdbc:h2:mem:testdb

spring.jpa.hibernate.ddl-auto=create

spring.jpa.show-sql=true

spring.h2.console.enabled=true

Any suggestions?

Thanks!


Solution

  • I found a solution:

    I had a circular dependency while I was trying to select the JOB-INSTANCE in an early stage before the embedded DB was configured.

    Changing the bean instantiation order fixed it.