spring-batch icon indicating copy to clipboard operation
spring-batch copied to clipboard

org/springframework/batch/core/schema-db2zos.sql is missing [BATCH-2527]

Open spring-projects-issues opened this issue 9 years ago • 1 comments

Andreas Otto opened BATCH-2527 and commented

Hi,

I'm not a really experienced Spring Developer, but I think, I have found a bug in the Spring System. Spring Batch knows a Databasetype ( org.springframework.batch.support.DatabaseType ) "DB2ZOS". But there is no "org/springframework/batch/core/schema-db2zos.sql" which fits.

To generate an Exception you simply have to generate a Spring Project which uses Spring Boot & Spring Batch together, configure a DB2.ZOS Database Connection in the Properties and annotate the same class that's annotated with @SpringBootApplication with @EnableBatchProcessing.

You get the exception

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchDatabaseInitializer': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.CannotReadScriptException: Cannot read SQL script from class path resource [org/springframework/batch/core/schema-db2zos.sql]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/batch/core/schema-db2zos.sql] cannot be opened because it does not exist


No further details from BATCH-2527

spring-projects-issues avatar Aug 19 '16 09:08 spring-projects-issues

Abdul Gaffar Khan commented

Hi, I am also facing similar issue below is log. class path resource [org/springframework/batch/core/schema-db2zos.sql] cannot be opened because it does not exist Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchDatabaseInitializer': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.CannotReadScriptException: Cannot read SQL script from class path resource [org/springframework/batch/core/schema-db2zos.sql]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/batch/core/schema-db2zos.sql] cannot be opened because it does not exist I am using resourcless transation below is my configuration. @Bean public ResourcelessTransactionManager transactionManager() { return new ResourcelessTransactionManager(); }

@Bean public JobRepository jobRepository(ResourcelessTransactionManager transactionManager) throws Exception { MapJobRepositoryFactoryBean mapJobRepositoryFactoryBean = new MapJobRepositoryFactoryBean(transactionManager); mapJobRepositoryFactoryBean.setTransactionManager(transactionManager); return mapJobRepositoryFactoryBean.getObject(); }

@Bean public SimpleJobLauncher jobLauncher(JobRepository jobRepository) { SimpleJobLauncher simpleJobLauncher = new SimpleJobLauncher(); simpleJobLauncher.setJobRepository(jobRepository); return simpleJobLauncher; }

spring-projects-issues avatar Aug 29 '16 16:08 spring-projects-issues

Spring Batch does not load DDL files or initialize the datasource with the corresponding schema. This is a feature of Spring Boot. I see nothing to do on the Batch side to fix this issue. Spring Boot should be updated to consider loading the org/springframework/batch/core/schema-db2.sql for a datasource of type DB2, DB2VSE, DB2ZOS or DB2AS400.

The only case I see an action to do on the Batch side is if those variants of DB2 use a different syntax, in which case we can consider adding a separate script for each variant in Spring Batch. Other than that, all variants of DB2 defined in org.springframework.batch.support.DatabaseType should be considered the same by Spring Boot and initialized with the main DB2 DDL script.

fmbenhassine avatar Nov 23 '22 10:11 fmbenhassine