Announcement Announcement Module
Collapse
No announcement yet.
How to re-run a job? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to re-run a job?

    Hi,

    I have defined a Spring Batch job which runs once just fine. However it is unable to run a second time due to a duplicate entry in the primary key for the JOB_INSTANCE_ID;

    Code:
    SEVERE: Job Terminated in error: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; Duplicate entry '0' for key 'PRIMARY'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '0' for key 'PRIMARY'
    I've read that this can be over-come by setting command line parameters on the job, e.g.

    Code:
    java -cp ${CLASSPATH} org.springframework.batch.core.launch.support.CommandLineJobRunner myJob.xml myJob date=20121025154016 -next
    Whether I include the -next parameter or not, it will not run the job.

    My Spring Batch configuration looks as follows (batch/launchContext.xml);

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans
            xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:batch="http://www.springframework.org/schema/batch"
            xmlns:context="http://www.springframework.org/schema/context"
            xmlns:util="http://www.springframework.org/schema/util"
            xmlns:jdbc="http://springframework.org/schema/jdbc"
            xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
    		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
    		http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
    		http://springframework.org/schema/jdbc http://springframework.org/schema/jdbc/spring-jdbc.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    
            <!-- Launch context: how to launch all of the jobs -->
            <!-- Expects a data source configuration file to be used, with a DataSource bean called "dataSource" -->
    
            <!-- The data source for the jobs status -->
            <import resource="dataSource.xml" />
    
            <bean
                    id="jobRepository"
                    class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
                    <property
                            name="dataSource"
                            ref="dataSource" />
                    <property
                            name="databaseType"
                            value="MySQL" />
                    <property
                            name="transactionManager"
                            ref="transactionManager"></property>
            </bean>
    
            <bean
                    id="incrementer"
                    class="org.springframework.batch.core.launch.support.RunIdIncrementer" />
    
            <bean
                    id="jobLauncher"
                    class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
                    <property
                            name="jobRepository"
                            ref="jobRepository" />
            </bean>
    
            <bean
                    id="transactionManager"
                    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
                    <property
                            name="dataSource"
                            ref="dataSource" />
            </bean>
    
            <bean
                    id="jobExplorer"
                    class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean">
                    <property
                            name="dataSource"
                            ref="dataSource" />
            </bean>
    
    </beans>
    And the job is like this (in the myJob.xml file)

    Code:
    ....
    <import resource="batch/launchContext.xml" />
    ...
    <batch:job
                    id="myJob"
                    job-repository="jobRepository"
                    incrementer="incrementer">
                    <batch:step id="step1">
                            <batch:tasklet transaction-manager="transactionManager">
                                    <batch:chunk
                                            reader="myReader"
                                            processor="myProcessor"
                                            writer="myWriter"
                                            commit-interval="10" />
                            </batch:tasklet>
                    </batch:step>
            </batch:job>
    Ideally what I'd like is each run of the job to be persisted with the run date/time. Is there a way to configure the launcher to do this automatically?

    Thanks,

    John

  • #2
    With regards to why you're getting that exception, do you have the full stack trace?

    Originally posted by johnmmcparland View Post
    Hi,
    Ideally what I'd like is each run of the job to be persisted with the run date/time.
    You could create your own implementation of the JobParametersIncrementer that generates a date as a given parameter.

    Comment


    • #3
      Thanks for your reply Michael.

      Originally posted by mminella View Post
      With regards to why you're getting that exception, do you have the full stack trace?
      Here it is;

      Code:
      SEVERE: Job Terminated in error: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; Duplicate entry '0' for key 'PRIMARY'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '0' for key 'PRIMARY'
      org.springframework.dao.DuplicateKeyException: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; Duplicate entry '0' for key 'PRIMARY'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '0' for key 'PRIMARY'
      	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:241)
      	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
      	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603)
      	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:812)
      	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:868)
      	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:872)
      	at org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.createJobInstance(JdbcJobInstanceDao.java:117)
      	at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:131)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean$1.invoke(AbstractJobRepositoryFactoryBean.java:168)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      	at $Proxy0.createJobExecution(Unknown Source)
      	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:111)
      	at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:349)
      	at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:574)
      Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '0' for key 'PRIMARY'
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      	at java.lang.reflect.Constructor.newInstance(Unknown Source)
      	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
      	at com.mysql.jdbc.Util.getInstance(Util.java:382)
      	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)
      	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
      	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
      	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
      	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
      	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
      	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2111)
      	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2407)
      	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2325)
      	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2310)
      	at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:818)
      	at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:1)
      	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:587)
      	... 21 more
      Originally posted by mminella View Post
      You could create your own implementation of the JobParametersIncrementer that generates a date as a given parameter.
      I hadn't thought of this, though I'm unsure whether it fits my approach. I'd like a common identifier across several jobs (basically to identify the trigger time of a set of jobs). However I'll give it a go.
      Last edited by johnmmcparland; Oct 29th, 2012, 05:59 AM.

      Comment


      • #4
        I created my own JobParametersIncrementer and used a JobOperator with my own main method rather than a JobLauncher & CommandLineRunner (I'd read I need to do this here)

        But I'm no further forward.

        Job
        Code:
          <batch:job
                        id="myJob" job-repository="jobRepository" incrementer="dateTimeIncr">
                        <batch:step id="step1">
                                <batch:tasklet transaction-manager="transactionManager">
                                        <batch:chunk reader="myReader" processor="myProcessor" writer="myWriter" commit-interval="10" />
                                </batch:tasklet>
                        </batch:step>
                </batch:job>
        The new launch context (batch/launchContext.xml). Note the addition of a JobRegistryBeanPostProcessor and a JobOperator.

        Code:
        <beans
                ... 
        >
                <import resource="dataSource.xml" />
        
                <bean
                        id="jobOperator" class="org.springframework.batch.core.launch.support.SimpleJobOperator">
                        <property name="jobExplorer" ref="jobExplorer" />
                        <property name="jobLauncher" ref="jobLauncher" />
                        <property name="jobRegistry" ref="jobRegistry" />
                        <property name="jobRepository" ref="jobRepository" />
                </bean>
        
                <bean
                        id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
                        <property  name="dataSource" ref="dataSource" />
                        <property name="databaseType" value="MySQL" />
                        <property name="transactionManager" ref="transactionManager" />
                </bean>
        
                <bean
                        id="dateTimeInc" class="my.batch.DateTimeIncrementer">
                        <property name="systemPropertyName" value="fetch.time" />
                </bean>
        
                <bean
                        id="jobLauncher"
                        class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
                        <property
                                name="jobRepository"
                                ref="jobRepository" />
                </bean>
        
                <bean
                        id="transactionManager"
                        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
                        <property
                                name="dataSource"
                                ref="dataSource" />
                </bean>
        
                <bean
                        id="jobExplorer"
                        class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean">
                        <property
                                name="dataSource"
                                ref="dataSource" />
                </bean>
        
                <bean
                        id="jobRegistry"
                        class="org.springframework.batch.core.configuration.support.MapJobRegistry" />
        
                <bean class="org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor">
                        <property
                                name="jobRegistry"
                                ref="jobRegistry" />
                </bean>
        </beans>
        The new main method;
        Code:
        public class EtlMain {
            public static void main(String args[]) {
                    String beanFile = args[0];
                    String jobName = args[1];
                    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(beanFile);
                    JobOperator jobOperator = context.getBean(JobOperator.class);
                    try {
                        jobOperator.startNextInstance(jobName);
                    } catch ...
                    ...
            } 
        }
        Running the job;
        Code:
        java -Dfetch.time=20121029121320 -cp ${CLSPTH} my.EtlMain myJob.xml myJob
        When I run the program, I expect it to use the DateTimeIncrementer to generate a new value, thus running the job time-after-time, providing the fetch.time is different.

        However I still get this exception

        Code:
        29-Oct-2012 12:16:51 org.springframework.batch.core.launch.support.SimpleJobOperator startNextInstance
        INFO: Locating parameters for next instance of job with name=muJob
        29-Oct-2012 12:16:51 org.springframework.batch.core.launch.support.SimpleJobOperator startNextInstance
        INFO: Attempting to launch job with name=myJob and parameters={fetch.time=1351506875000, run.id=1}
        29-Oct-2012 12:16:51 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
        INFO: Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
        29-Oct-2012 12:16:51 org.springframework.jdbc.support.SQLErrorCodesFactory <init>
        INFO: SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
        SEVERE: Job Terminated in error: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; Duplicate entry '0' for key 'PRIMARY'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '0' for key 'PRIMARY'
        org.springframework.dao.DuplicateKeyException: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; Duplicate entry '0' for key 'PRIMARY'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '0' for key 'PRIMARY'
        	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:241)
        	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
        	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603)
        	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:812)
        	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:868)
        	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:872)
        	at org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.createJobInstance(JdbcJobInstanceDao.java:117)
        	at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:131)
        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        	at java.lang.reflect.Method.invoke(Unknown Source)
        	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
        	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
        	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        	at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean$1.invoke(AbstractJobRepositoryFactoryBean.java:168)
        	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        	at $Proxy0.createJobExecution(Unknown Source)
        	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:111)
        	at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:349)
        	at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:574)
        Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '0' for key 'PRIMARY'
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        	at java.lang.reflect.Constructor.newInstance(Unknown Source)
        	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
        	at com.mysql.jdbc.Util.getInstance(Util.java:382)
        	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)
        	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
        	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
        	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
        	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
        	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
        	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2111)
        	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2407)
        	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2325)
        	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2310)
        	at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:818)
        	at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:1)
        	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:587)
        	... 21 more
        This is in spite of the fact the fetch.time property has been set to something new!

        Does run.id need incremented? How may I configure the job such that this is auto-incremented?

        Comment


        • #5
          At long last I figured this out.

          I didn't have to change any of my Spring configuration from the first example (except if I wished to include the date/time parameter).

          In fact what was wrong was the way I deleted the data from the Spring Batch tables. I was deleting rows which are inserted upon creation. So I updated my delete SQL to this;

          Code:
          -- Autogenerated: do not edit this file
          
          CREATE TABLE BATCH_JOB_INSTANCE  (
          	JOB_INSTANCE_ID BIGINT  NOT NULL PRIMARY KEY ,
          	VERSION BIGINT ,
          	JOB_NAME VARCHAR(100) NOT NULL,
          	JOB_KEY VARCHAR(32) NOT NULL,
          	constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
          ) ENGINE=InnoDB;
          
          CREATE TABLE BATCH_JOB_EXECUTION  (
          	JOB_EXECUTION_ID BIGINT  NOT NULL PRIMARY KEY ,
          	VERSION BIGINT  ,
          	JOB_INSTANCE_ID BIGINT NOT NULL,
          	CREATE_TIME DATETIME NOT NULL,
          	START_TIME DATETIME DEFAULT NULL ,
          	END_TIME DATETIME DEFAULT NULL ,
          	STATUS VARCHAR(10) ,
          	EXIT_CODE VARCHAR(100) ,
          	EXIT_MESSAGE VARCHAR(2500) ,
          	LAST_UPDATED DATETIME,
          	constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
          	references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
          ) ENGINE=InnoDB;
          
          CREATE TABLE BATCH_JOB_PARAMS  (
          	JOB_INSTANCE_ID BIGINT NOT NULL ,
          	TYPE_CD VARCHAR(6) NOT NULL ,
          	KEY_NAME VARCHAR(100) NOT NULL ,
          	STRING_VAL VARCHAR(250) ,
          	DATE_VAL DATETIME DEFAULT NULL ,
          	LONG_VAL BIGINT ,
          	DOUBLE_VAL DOUBLE PRECISION ,
          	constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
          	references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
          ) ENGINE=InnoDB;
          
          CREATE TABLE BATCH_STEP_EXECUTION  (
          	STEP_EXECUTION_ID BIGINT  NOT NULL PRIMARY KEY ,
          	VERSION BIGINT NOT NULL,
          	STEP_NAME VARCHAR(100) NOT NULL,
          	JOB_EXECUTION_ID BIGINT NOT NULL,
          	START_TIME DATETIME NOT NULL ,
          	END_TIME DATETIME DEFAULT NULL ,
          	STATUS VARCHAR(10) ,
          	COMMIT_COUNT BIGINT ,
          	READ_COUNT BIGINT ,
          	FILTER_COUNT BIGINT ,
          	WRITE_COUNT BIGINT ,
          	READ_SKIP_COUNT BIGINT ,
          	WRITE_SKIP_COUNT BIGINT ,
          	PROCESS_SKIP_COUNT BIGINT ,
          	ROLLBACK_COUNT BIGINT ,
          	EXIT_CODE VARCHAR(100) ,
          	EXIT_MESSAGE VARCHAR(2500) ,
          	LAST_UPDATED DATETIME,
          	constraint JOB_EXEC_STEP_FK foreign key (JOB_EXECUTION_ID)
          	references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
          ) ENGINE=InnoDB;
          
          CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT  (
          	STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
          	SHORT_CONTEXT VARCHAR(2500) NOT NULL,
          	SERIALIZED_CONTEXT TEXT ,
          	constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
          	references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
          ) ENGINE=InnoDB;
          
          CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT  (
          	JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
          	SHORT_CONTEXT VARCHAR(2500) NOT NULL,
          	SERIALIZED_CONTEXT TEXT ,
          	constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
          	references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
          ) ENGINE=InnoDB;
          
          CREATE TABLE BATCH_STEP_EXECUTION_SEQ (ID BIGINT NOT NULL) ENGINE=MYISAM;
          INSERT INTO BATCH_STEP_EXECUTION_SEQ values(0);
          CREATE TABLE BATCH_JOB_EXECUTION_SEQ (ID BIGINT NOT NULL) ENGINE=MYISAM;
          INSERT INTO BATCH_JOB_EXECUTION_SEQ values(0);
          CREATE TABLE BATCH_JOB_SEQ (ID BIGINT NOT NULL) ENGINE=MYISAM;
          INSERT INTO BATCH_JOB_SEQ values(0);
          You can see in those last 6 lines there are three insertions. My delete script removed those. When I updated the delete script to re-insert those rows, it all worked!

          Code:
          DELETE FROM BATCH_STEP_EXECUTION_CONTEXT ;
          DELETE FROM BATCH_JOB_EXECUTION_CONTEXT ;
          DELETE FROM BATCH_STEP_EXECUTION ;
          DELETE FROM BATCH_JOB_EXECUTION ;
          DELETE FROM BATCH_JOB_PARAMS ;
          DELETE FROM BATCH_JOB_INSTANCE ;
          
          DELETE FROM BATCH_STEP_EXECUTION_SEQ ;
          DELETE FROM BATCH_JOB_EXECUTION_SEQ ;
          DELETE FROM BATCH_JOB_SEQ ;
          
          -- These are needed
          INSERT INTO BATCH_STEP_EXECUTION_SEQ values(0);
          INSERT INTO BATCH_JOB_EXECUTION_SEQ values(0);
          INSERT INTO BATCH_JOB_SEQ values(0);
          BTW I now have a small example project which shows how to persist the Spring Batch meta-data. Could I contribute this to the project somehow? E.g. add to the samples or place on the website somewhere?

          Comment

          Working...
          X