2

I am using Spring Batch 3.0.5 and Spring Boot, along with job launcher, but whenever I run my job I get the following error:

org.springframework.jdbc.BadSqlGrammarException:
    PreparedStatementCallback; bad SQL grammar [SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?];
    nested exception is java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: BATCH_JOB_EXECUTION

Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: BATCH_JOB_EXECUTION
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 org.springframework.jdbc.core.JdbcTemplate$SimplePreparedStatementCreator.createPreparedStatement(JdbcTemplate.java:1557)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:638)

Caused by: org.springframework.dao.ConcurrencyFailureException:
    PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)];
    transaction rollback: serialization failure; nested exception is java.sql.SQLTransactionRollbackException: transaction rollback: serialization failure

Edit: The error resolved itself when I updated Spring from version 4.0.0 release to 4.2.3 release.

Now the batch is running but it is not executing the steps after first run.

During the first run I get the following error:

ERROR 8442 --- o.s.s.s.TaskUtils$LoggingErrorHandler    : Unexpected error occurred in scheduled task.
org.springframework.dao.ConcurrencyFailureException: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; transaction rollback: serialization failure; nested exception is java.sql.SQLTransactionRollbackException: transaction rollback: serialization failure

and the after each run of the batch I am getting following output in the command line.

INFO 8442 --- com.capitalone.schduler.BatchScheduler   : sendMailToCustomers Job ran at 11/10/2016 10:37:06
INFO 8442 --- com.capitalone.schduler.BatchScheduler   : triggering BatchConfiguration at time {}11/10/2016 10:37:06
INFO 8442 --- o.s.b.c.l.support.SimpleJobLauncher      : Job: [FlowJob: [name=queueInfoStep]] launched with the following parameters: [{JOB_START_DATE=Thu Nov 10 10:37:06 EST 2016}]
INFO 8442 --- o.s.batch.core.job.SimpleStepHandler     : Executing step: [queueInfoStep]
INFO 8442 --- o.s.b.c.l.support.SimpleJobLauncher      : Job: [FlowJob: [name=queueInfoStep]] completed with the following parameters: [{JOB_START_DATE=Thu Nov 10 10:37:06 EST 2016}] and the following status: [COMPLETED]
Addison
  • 7,322
  • 2
  • 39
  • 55

3 Answers3

1

It seems that you either have not yet created the table/view BATCH_JOB_EXECUTION, or perhaps have not granted yourself permission to it, since your error is saying:

user lacks privilege or object not found: BATCH_JOB_EXECUTION

Make sure that you're entering in the right set of credentials too - if you made the table with one username, you could be trying to access it with a different username and password.

Addison
  • 7,322
  • 2
  • 39
  • 55
1

Make sure you specify the initialization script to create your Spring Batch framework tables. The DDL for various databases is bundled in spring-batch-core.

This would go in your test context file:

<jdbc:embedded-database id="dataSource" type="HSQL">
    <jdbc:script location="classpath:/org/springframework/batch/core/schema-hsqldb.sql" />
</jdbc:embedded-database>
Dean Clark
  • 3,770
  • 1
  • 11
  • 26
  • Hello Dean,I am using java configuration not the xml version, is there a way to do the same in java configuration. I am looking for a way to tell spring not to store the data HSQLDB beyond certain limit, as over time it grows and creates trouble. – ppmohapatra Dec 01 '16 at 21:16
0

All because of jar version missmatch. A specific combination of spring boot, spring batch and spring core only works. Any version miss match ends up in error like the one I have faced.