spring-batch

SpringBoot JNDI datasource throws java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory

橙三吉。 提交于 2019-12-01 04:06:33
问题 Similar questions have been asked before and I went through all of those but not able to solve problem. Related Questions - Q1,Q2,Q3, Q4, Q5, Q6 I have a Spring Batch project with Spring Boot and trying to use DB connection pools. I am using embedded tomcat container with version 8.5.x. Everything works fine if I use application.properties to specify data source and pool settings. But when I try to use JNDI, I get exception - Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.dbcp

Failed to execute CommandLineRunner - Spring Batch

谁都会走 提交于 2019-12-01 03:50:17
问题 Hi I am very new to Spring batch and I am getting the following exception which I am not able to resolve: java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:781) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.run

Duplicate Spring Batch Job Instance

久未见 提交于 2019-12-01 03:38:28
问题 I have a small sample Spring Batch application that when started for the first time will work fine but whenever I shut the application down & restart the jar I always get this error: Caused by: org.springframework.dao.DuplicateKeyException: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; Duplicate entry '1' for key 1; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:

Spring Batch Table Prefix when using Java Config

折月煮酒 提交于 2019-12-01 03:24:37
问题 My Spring Batch repository (deployed on an Oracle database) lies in a different schema such that I need to prepend the schema name. When using XML configuration, this would be easy to do: <job-repository id="jobRepository" table-prefix="GFA.BATCH_" /> However, as I use Java Config, this turns out to be more tricky. The best solution I found is to have my Java Config class extend DefaultBatchConfigurer and override the createJobRepository() method: @Configuration @EnableBatchProcessing public

How to get job id using spring expression language?

吃可爱长大的小学妹 提交于 2019-12-01 03:13:43
问题 I want to get job id using spring expression language. I tried #{jobExecutionContext[jobId]} but it does not work. 回答1: Using SpEL alone, there is no way to access the job id. You could use a JobExecutionListener to add it to the executionContext and then it would be available via what you are trying. 回答2: A worked example would look like this. Your JobExecutionListener class has access to the JobExecution and it copies the jobId to the executionContext. public class

How does Spring Batch CompositeItemWriter manage transaction for delegate writers?

£可爱£侵袭症+ 提交于 2019-12-01 02:34:15
In the batch job step configuration, I plan to execute 2 queries in the writer, the 1st query is to update records in table A, then the 2nd query is to insert new records in table A again. So far I think CompositeItemWriter can achieve my goal above, i.e., I need to create 2 JdbcBatchItemWriters, one is for update, and the other one is for insert. My first question is if CompositeItemWriter is a fit for the requirement above? If yes, that lead to the second question about transaction. For example, if the first update is successful, and the second insert fails. Will the 1st update transaction

Spring-batch flow / split after a step

别来无恙 提交于 2019-12-01 02:12:28
问题 I am building a spring-batch solution that contains the following process: step 1 : split a list into multiple lists step 2 : process each sub-list step 3 : merge sub-lists The generated sub-lists can be processed in parallel, and according to the spring-batch documentation this is supported. Sadly I can only find spring-batch example jobs that start with parallel steps, not examples that start out sequentially. The following job will not compile. Spring gives me an error: 'cannot resolve

Need to configure my JPA layer to use a TransactionManager (Spring Cloud Task + Batch register a PlatformTransactionManager unexpectedly)

岁酱吖の 提交于 2019-12-01 01:42:30
I am using Spring Cloud Task + Batch in a project. I plan to use different datasources for business data and Spring audit data on the task. So I configured something like: @Bean public TaskConfigurer taskConfigurer() { return new DefaultTaskConfigurer(this.singletonNotExposedSpringDatasource()); } @Bean public BatchConfigurer batchConfigurer() { return new DefaultBatchConfigurer(this.singletonNotExposedSpringDatasource()); } whereas main datasource is autoconfigured through JpaBaseConfiguration . The problem comes when SimpleBatchConfiguration + DefaultBatchConfigurer expose a

Moving processed files in remote S(ftp) using Java DSL

主宰稳场 提交于 2019-12-01 00:15:33
I'm trying to move files on remote SFTP once the batch has successfully processed the files using Spring integration and Java DSL. What would be the best way to achieve that? Adding a step in batch to move remote files ? Or using FTP Outbound Gateway and provide the MV command ? I tend to prefer the second solution and let the batch focus on the logic only, but I've hard times trying to implement it with java dsl. I've read http://docs.spring.io/spring-integration/reference/html/ftp.html#ftp-outbound-gateway and tried to implement like that : @Bean public MessageHandler ftpOutboundGateway() {

Making a item reader to return a list instead single object - Spring batch

泄露秘密 提交于 2019-11-30 22:35:49
Question is : How to make an Item reader in spring batch to deliver a list instead of a single object. I have searched across, some answers are to modify the item reader to return list of objects and changing item processor to accept a list as input. How to do/code the item reader ? Michael Pralow take a look at the official spring batch documentation for itemReader public interface ItemReader<T> { T read() throws Exception, UnexpectedInputException, ParseException; } // so it is as easy as public class ReturnsListReader implements ItemReader<List<?>> { public List<?> read() throws Exception {