Search This Blog

Thursday 21 May 2015

Introducing database to Spring Batch

Until now we have seen Spring batch without its meta data persistence features. When I say meta-data for Spring batch it includes batch related information - a listing of the steps executed, and their audit information, how many items did the framework read/write, did it skip any items, what was the duration of each step executed etc. This meta data is maintained in a database - persistence.
To keep things easy we used in memory implementations of the batch classes - these implementations ran with Maps. Spring recommends that the Map based implementation be used only for application testing. For batch applications in the real world Spring recommends the database linked code:
"Note that the in-memory repository is volatile and so does not allow restart between JVM instances. 
It also cannot guarantee that two job instances with the same parameters are launched simultaneously, 
and is not suitable for use in a multi-threaded Job, or a locally partitioned Step. So use the 
database version of the repository wherever you need those features."
So I decided to introduce the database to my batch example. The changes were only needed in the configuration:
<beans:bean id="jobRepository"
      class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
      <beansroperty name="transactionManager" ref="transactionManager" />
      <beansroperty name="dataSource" ref="dataSource" />
   </beans:bean>
the JobRepository class has been changed from MapJobRepositoryFactoryBean to JobRepositoryFactoryBean. This class needs to have the dataSource property initialized. I decided to go with a postgres database:
<beans:bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <beans:property name="driverClassName" value="org.postgresql.Driver" />
      <beans:property name="url"
         value="jdbcostgresql://localhost:5433/batchTest" />
      <bean:psroperty name="username" value="postgres" />
      <bean:psroperty name="password" value="#######" />
   </beans:bean>
The other class that need to be changed is the TransactionManager:
<beans:bean id="transactionManager"
      class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      <beans:property name="dataSource" ref="dataSource" />
   </beans:bean>
This replaces the ResourcelessTransactionManager. If I run the code now:
11:53:45.589 [main] INFO  o.s.j.support.SQLErrorCodesFactory - SQLErrorCodes loaded: 
[DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
11:53:45.589 [main] DEBUG o.s.j.support.SQLErrorCodesFactory - Looking up default 
SQLErrorCodes for DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@464d02ee]
11:53:45.589 [main] DEBUG o.s.j.support.SQLErrorCodesFactory - Database product name cached for 
DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@464d02ee]: name is 'PostgreSQL'
11:53:45.589 [main] DEBUG o.s.j.support.SQLErrorCodesFactory - SQL error codes for 'PostgreSQL' found
11:53:45.590 [main] DEBUG o.s.j.s.SQLErrorCodeSQLExceptionTranslator 
- Translating SQLException with SQL state '42P01', error code '0', message [ERROR: relation 
"batch_job_instance" does not exist
  Position: 39]; SQL was [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where 
JOB_NAME = ? and JOB_KEY = ?] for task [PreparedStatementCallback]
11:53:45.590 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction rollback
The code failed as Spring batch did not find the tables necessary for the code to run. I had expected that the tables would be auto generated, like Hibernate's DDLcommand. To get the table scripts to execute we need to add the below XML element:
<jdbc:initialize-database data-source="dataSource">
      <jdbc:script
         location="org/springframework/batch/core/schema-drop-postgresql.sql" />
      <jdbc:script
         location="org/springframework/batch/core/schema-postgresql.sql" />
   </jdbc:initialize-database>
This tells Spring to load the scripts from the org.springframework.batch.core package. Within this folder (its the spring-batch-core jar) there are present such drop and create scripts for several databases. Now if I were to run the code:
13:18:00.641 [main] DEBUG o.s.b.f.xml.XmlBeanDefinitionReader - Loaded 20 bean definitions from location pattern [spring-config-db.xml]
...
13:18:00.853 [main] DEBUG o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
13:18:00.853 [main] DEBUG o.s.j.d.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbcostgresql://localhost:5433/batchTest]
13:18:00.928 [main] DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
13:18:00.928 [main] INFO  o.s.b.c.r.s.JobRepositoryFactoryBean - No database type set, using meta data indicating: POSTGRES
13:18:01.013 [main] DEBUG o.s.t.i.NameMatchTransactionAttributeSource - Adding transactional method [*] with attribute 
[PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
13:18:01.013 [main] DEBUG o.s.t.i.NameMatchTransactionAttributeSource - Adding transactional method [create*] with attribute 
[PROPAGATION_REQUIRES_NEW,ISOLATION_SERIALIZABLE]
13:18:01.013 [main] DEBUG o.s.t.i.NameMatchTransactionAttributeSource - Adding transactional method [getLastJobExecution*] 
with attribute [PROPAGATION_REQUIRES_NEW,ISOLATION_SERIALIZABLE]
...
13:18:01.114 [main] DEBUG o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
13:18:01.114 [main] DEBUG o.s.j.d.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbcostgresql://localhost:5433/batchTest]
13:18:01.132 [main] INFO  o.s.jdbc.datasource.init.ScriptUtils - Executing SQL script from class path resource 
[org/springframework/batch/core/schema-drop-postgresql.sql]
...
13:18:01.143 [main] INFO  o.s.jdbc.datasource.init.ScriptUtils - Executed SQL script from class path resource 
[org/springframework/batch/core/schema-drop-postgresql.sql] in 10 ms.
13:18:01.143 [main] INFO  o.s.jdbc.datasource.init.ScriptUtils - Executing SQL script from class path resource 
[org/springframework/batch/core/schema-postgresql.sql]
13:18:01.479 [main] INFO  o.s.jdbc.datasource.init.ScriptUtils - Executed SQL script from class path resource 
[org/springframework/batch/core/schema-postgresql.sql] in 336 ms.
As seen now, on startup spring batch executed the relevant drop and create scripts. The database schema for batch is as below:
This is when the job runs:
13:18:01.522 [main] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL statement [SELECT JOB_INSTANCE_ID, JOB_NAME
 from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]
13:18:01.531 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Creating new transaction with name 
[org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution]: PROPAGATION_REQUIRES_NEW,ISOLATION_SERIALIZABLE
SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?
INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)
INSERT into BATCH_JOB_EXECUTION(JOB_EXECUTION_ID, JOB_INSTANCE_ID, START_TIME, END_TIME,
 STATUS, EXIT_CODE, EXIT_MESSAGE, VERSION, CREATE_TIME, LAST_UPDATED, JOB_CONFIGURATION_LOCATION) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
INSERT INTO BATCH_JOB_EXECUTION_CONTEXT (SHORT_CONTEXT, SERIALIZED_CONTEXT, JOB_EXECUTION_ID) VALUES(?, ?, ?)
Initiating transaction commit:
13:18:01.583 [main] INFO  o.s.b.c.l.support.SimpleJobLauncher - Job: [FlowJob: [name=reportJob]] launched with the following parameters: [{}]
13:18:01.583 [main] DEBUG o.s.batch.core.job.AbstractJob - Job execution starting: JobExecution: id=1, version=0, startTime=null, endTime=null, 
lastUpdated=Tue Feb 24 13:18:01 CST 2015, status=STARTING, exitStatus=exitCode=UNKNOWN;
exitDescription=, job=[JobInstance: id=1, version=0, Job=[reportJob]], jobParameters=[{}]
13:18:01.586 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Creating new transaction with name 
[org.springframework.batch.core.repository.support.SimpleJobRepository.update]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?
UPDATE BATCH_JOB_EXECUTION set START_TIME = ?, END_TIME = ?,  STATUS = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, 
CREATE_TIME = ?, LAST_UPDATED = ? where JOB_EXECUTION_ID = ? and VERSION = ?
SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION,
 JOB_CONFIGURATION_LOCATION from BATCH_JOB_EXECUTION where JOB_INSTANCE_ID = ? order by JOB_EXECUTION_ID desc
SELECT JOB_EXECUTION_ID, KEY_NAME, TYPE_CD, STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL, IDENTIFYING 
from BATCH_JOB_EXECUTION_PARAMS where JOB_EXECUTION_ID = ?
SELECT STEP_EXECUTION_ID, STEP_NAME, START_TIME, END_TIME, STATUS, COMMIT_COUNT, READ_COUNT, FILTER_COUNT, WRITE_COUNT, 
EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, PROCESS_SKIP_COUNT, ROLLBACK_COUNT, LAST_UPDATED, VERSION 
from BATCH_STEP_EXECUTION where JOB_EXECUTION_ID = ? order by STEP_EXECUTION_ID
13:18:01.639 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction commit
SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION, 
JOB_CONFIGURATION_LOCATION from BATCH_JOB_EXECUTION where JOB_INSTANCE_ID = ? order by JOB_EXECUTION_ID desc
SELECT JOB_EXECUTION_ID, KEY_NAME, TYPE_CD, STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL, IDENTIFYING 
from BATCH_JOB_EXECUTION_PARAMS where JOB_EXECUTION_ID = ?
SELECT STEP_EXECUTION_ID, STEP_NAME, START_TIME, END_TIME, STATUS, COMMIT_COUNT, READ_COUNT, FILTER_COUNT, 
WRITE_COUNT, EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, PROCESS_SKIP_COUNT, ROLLBACK_COUNT, LAST_UPDATED, 
VERSION from BATCH_STEP_EXECUTION where JOB_EXECUTION_ID = ? order by STEP_EXECUTION_ID
Initiating transaction commit
SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION, JOB_CONFIGURATION_LOCATION 
from BATCH_JOB_EXECUTION where JOB_INSTANCE_ID = ? order by JOB_EXECUTION_ID desc]
13:18:01.681 [main] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL query
13:18:01.681 [main] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL statement [SELECT JOB_EXECUTION_ID, KEY_NAME, TYPE_CD, STRING_VAL, DATE_VAL, 
LONG_VAL, DOUBLE_VAL, IDENTIFYING from BATCH_JOB_EXECUTION_PARAMS where JOB_EXECUTION_ID = ?]
13:18:01.682 [main] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL query
13:18:01.682 [main] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL statement [SELECT STEP_EXECUTION_ID, STEP_NAME, START_TIME, END_TIME, STATUS,
 COMMIT_COUNT, READ_COUNT, FILTER_COUNT, WRITE_COUNT, EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, PROCESS_SKIP_COUNT, 
ROLLBACK_COUNT, LAST_UPDATED, VERSION from BATCH_STEP_EXECUTION where JOB_EXECUTION_ID = ? order by STEP_EXECUTION_ID]
13:18:01.683 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction commit
13:18:01.684 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Creating new transaction with name [org.springframework.batch.core.repository.support.SimpleJobRepository.add]: 
PROPAGATION_REQUIRED,ISOLATION_DEFAULT
INSERT into BATCH_STEP_EXECUTION(STEP_EXECUTION_ID, VERSION, STEP_NAME, JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, COMMIT_COUNT, 
READ_COUNT, FILTER_COUNT, WRITE_COUNT, EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, PROCESS_SKIP_COUNT, ROLLBACK_COUNT, 
LAST_UPDATED) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)         
INSERT INTO BATCH_STEP_EXECUTION_CONTEXT (SHORT_CONTEXT, SERIALIZED_CONTEXT, STEP_EXECUTION_ID) VALUES(?, ?, ?)
13:18:01.708 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction commit
13:18:01.711 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Creating new transaction with name [org.springframework.batch.core.repository.support.SimpleJobRepository.update]: 
PROPAGATION_REQUIRED,ISOLATION_DEFAULT
UPDATE BATCH_STEP_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, COMMIT_COUNT = ?, READ_COUNT = ?, FILTER_COUNT = ?, WRITE_COUNT = ?, 
EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, READ_SKIP_COUNT = ?, PROCESS_SKIP_COUNT = ?, WRITE_SKIP_COUNT = ?, ROLLBACK_COUNT = ?, LAST_UPDATED = ? 
where STEP_EXECUTION_ID = ? and VERSION = ?
SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?
13:18:01.733 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction commit
Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
Converting (firstName: Robin, lastName: Varghese) into (firstName: ROBIN, lastName: VARGHESE)
Converting (firstName: Rohan, lastName: Naidu) into (firstName: ROHAN, lastName: NAIDU)
13:18:01.805 [main] DEBUG o.s.b.c.s.item.ChunkOrientedTasklet - Inputs not busy, ended: false
13:18:01.805 [main] DEBUG o.s.b.core.step.tasklet.TaskletStep - Applying contribution: [StepContribution: read=2, 
written=2, filtered=0, readSkips=0, writeSkips=0, 
processSkips=0, exitStatus=EXECUTING]
UPDATE BATCH_STEP_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE STEP_EXECUTION_ID = ?
13:18:01.808 [main] DEBUG o.s.b.core.step.tasklet.TaskletStep - Saving step execution before commit: StepExecution: id=1, version=1, name=step1, status=STARTED, 
exitStatus=EXECUTING, readCount=2, filterCount=0, writeCount=2 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=1, rollbackCount=0, exitDescription=1
UPDATE BATCH_STEP_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, COMMIT_COUNT = ?, READ_COUNT = ?, FILTER_COUNT = ?, WRITE_COUNT = ?, 
EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, READ_SKIP_COUNT = ?, PROCESS_SKIP_COUNT = ?, WRITE_SKIP_COUNT = ?, ROLLBACK_COUNT = ?, LAST_UPDATED = ? 
where STEP_EXECUTION_ID = ? and VERSION = ?]
SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?
13:18:01.810 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction commit
13:18:01.814 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
Converting (firstName: Roman, lastName: Barlan) into (firstName: ROMAN, lastName: BARLAN)
13:18:01.834 [main] DEBUG o.s.b.core.step.tasklet.TaskletStep - Applying contribution: [StepContribution: read=1, written=1, filtered=0, readSkips=0, writeSkips=0, processSkips=0, exitStatus=EXECUTING]
UPDATE BATCH_STEP_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE STEP_EXECUTION_ID = ?
13:18:01.836 [main] DEBUG o.s.b.core.step.tasklet.TaskletStep - Saving step execution before commit: StepExecution: id=1, version=2, name=step1, status=STARTED, 
exitStatus=EXECUTING, readCount=3, filterCount=0, writeCount=3 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=2, rollbackCount=0, exitDescription=
UPDATE BATCH_STEP_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, COMMIT_COUNT = ?, READ_COUNT = ?, FILTER_COUNT = ?, 
WRITE_COUNT = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, READ_SKIP_COUNT = ?, PROCESS_SKIP_COUNT = ?, WRITE_SKIP_COUNT = ?, ROLLBACK_COUNT = ?, 
LAST_UPDATED = ? where STEP_EXECUTION_ID = ? and VERSION = ?
SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?
13:18:01.838 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction commit
UPDATE BATCH_STEP_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE STEP_EXECUTION_ID = ?
13:18:01.861 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction commit
13:18:01.864 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Creating new transaction with name 
[org.springframework.batch.core.repository.support.SimpleJobRepository.update]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
UPDATE BATCH_STEP_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, COMMIT_COUNT = ?, READ_COUNT = ?, FILTER_COUNT = ?, 
WRITE_COUNT = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, READ_SKIP_COUNT = ?, PROCESS_SKIP_COUNT = ?, WRITE_SKIP_COUNT = ?, 
ROLLBACK_COUNT = ?, LAST_UPDATED = ? where STEP_EXECUTION_ID = ? and VERSION = ?
SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?
13:18:01.886 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction commit
13:18:01.894 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Creating new transaction with name 
[org.springframework.batch.core.repository.support.SimpleJobRepository.updateExecutionContext]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
UPDATE BATCH_STEP_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE STEP_EXECUTION_ID = ?
UPDATE BATCH_STEP_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, COMMIT_COUNT = ?, READ_COUNT = ?, FILTER_COUNT = ?, 
WRITE_COUNT = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, READ_SKIP_COUNT = ?, PROCESS_SKIP_COUNT = ?, WRITE_SKIP_COUNT = ?, 
ROLLBACK_COUNT = ?, LAST_UPDATED = ? where STEP_EXECUTION_ID = ? and VERSION = ?
SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?
13:18:01.886 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction commit
13:18:01.894 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Creating new transaction with name 
[org.springframework.batch.core.repository.support.SimpleJobRepository.updateExecutionContext]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
UPDATE BATCH_JOB_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE JOB_EXECUTION_ID = ?
13:18:01.919 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction commit
...
13:18:01.923 [main] DEBUG o.s.b.c.job.flow.support.SimpleFlow - Completed state=reportJob.step1 with status=COMPLETED
13:18:01.923 [main] DEBUG o.s.b.c.job.flow.support.SimpleFlow - Handling state=reportJob.end1
13:18:01.923 [main] DEBUG o.s.b.c.job.flow.support.SimpleFlow - Completed state=reportJob.end1 with status=COMPLETED
SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?
SELECT COUNT FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID = ?
UPDATE BATCH_JOB_EXECUTION set START_TIME = ?, END_TIME = ?,  STATUS = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, CREATE_TIME = ?, 
LAST_UPDATED = ? where JOB_EXECUTION_ID = ? and VERSION = ?
...
13:18:01.948 [main] INFO  o.s.b.c.l.support.SimpleJobLauncher - Job: [FlowJob: [name=reportJob]] 
completed with the following parameters: [{}] and the following status: [COMPLETED]
Exit Status : COMPLETED
Found <firstName: ROBIN, lastName: VARGHESE> in the result.
Found <firstName: ROHAN, lastName: NAIDU> in the result.
Found <firstName: ROMAN, lastName: BARLAN> in the result.
...
Done

8 comments:

  1. As you mentioned in your post, I did change like :
    1)


    2)



    3)




    But I am getting error like :
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobRepository' defined in class path resource [jobs/jobs-infra.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: DataSource must not be null.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:684)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
    at com.spi.spring.App.main(App.java:18)
    Caused by: java.lang.IllegalArgumentException: DataSource must not be null.
    at org.springframework.util.Assert.notNull(Assert.java:112)
    at org.springframework.batch.core.repository.support.JobRepositoryFactoryBean.afterPropertiesSet(JobRepositoryFactoryBean.java:153)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
    ... 12 more

    ReplyDelete
  2. 1. From "MapJobRepositoryFactoryBean" to "JobRepositoryFactoryBean"
    2. From "MapDataSourceTransactionManager" to "DataSourceTransactionManager"
    3. Added "jdbc:initialize-database" element in configuration file.
    But when I do first and second , I got the above mentioned error.

    ReplyDelete
  3. Hello, the error is gone but the meta-data tables are not getting updated.

    ReplyDelete
  4. Now meta-data tables are getting updated. The issue was with MySQL schema.

    ReplyDelete
  5. How r u able to log the whole script?what is the logger package u referred here?

    ReplyDelete
  6. https://stackoverflow.com/questions/25044725/is-there-a-spring-batch-3-upgrade-script-for-mysql

    Added this column in 3.0 onward , please refer the link

    ReplyDelete
  7. You are carrying out a pretty good mission in providing this sort of practical help and advice. This is just exactly what I was finding.
    bulk url opener for android
    GoogleTune

    ReplyDelete