EnableEmbeddedSpringBatchLightminServer: Initialization of the spring batch database fails
See original GitHub issueWhen I run this:
code: https://github.com/tuxdevelop/spring-batch-lightmin#enable-the-server-1
application.properties:
spring.batch.lightmin.application-name=test
# Datasource
spring.datasource.url=jdbc:h2:mem:~/test
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>springbatchtest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>springbatchtest</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.tuxdevelop</groupId>
<artifactId>spring-batch-lightmin-server</artifactId>
<version>0.4.1</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I get:
2017-09-25 20:49:08.923 ERROR 15148 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT * FROM BATCH_JOB_CONFIGURATION WHERE application_name = ? AND job_name IN ()]; nested exception is org.h2.jdbc.JdbcSQLException: Tabelle "BATCH_JOB_CONFIGURATION" nicht gefunden
Table "BATCH_JOB_CONFIGURATION" not found; SQL statement:
SELECT * FROM BATCH_JOB_CONFIGURATION WHERE application_name = ? AND job_name IN () [42102-196]
I works fine if I use @EnableSpringBatchLightminServer
instead of @EnableEmbeddedSpringBatchLightminServer
, e.g. the example given in:
https://github.com/tuxdevelop/spring-batch-lightmin#enable-the-server
Thanks for providing spring-batch-lightmin by the way! 👍
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Spring-Batch without persisting metadata to database?
Simply create a configuration without datasource for Batch configuration : @Configuration @EnableAutoConfiguration @EnableBatchProcessing public class ...
Read more >Spring Batch - Reference Documentation
If, for instance, the reader , writer , and tasklet attributes are left off of a Step configuration, then initialization fails. If a...
Read more >Working With Spring Batch and Distributed Transaction
Spring Batch is a great tool to deal with large data volume, the project introduces the chunk-oriented processing, that divides data into batches, ......
Read more >71.Spring Boot-Initialize a Spring Batch database - YouTube
In this video you will learn How to Initialize a Spring Batch database in Spring BootBelow is the GitHub link to download ...
Read more >Testing a Spring Batch Job - Baeldung
The first thing we'll test is a complete end-to-end Job with a small data-set input. We can then compare the results with an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @ramchris , also sorry here for my late reply, if you configure a second datasource for the spring_batch and lightmin tables, you can assign it to server via the following properties
For the lightmin tables:
spring.batch.lightmin.data-source-name=spring bean name of the datasource
for the spring batch tables
spring.batch.lightmin.batch-data-source=spring bean name of the datasource
In your example, you should have two datasources, one for your application and one for spring batch/lightmin
@Bean @Primary //if it should be the default for spring boot public DataSource applicationDataSource(){
}
@Bean @Qualifier(“batchDataSource”) public DataSource batchDataSource(){
}
In this example, the properties should look like this
spring.batch.lightmin.data-source-name=batchDataSource
spring.batch.lightmin.batch-data-source=batchDataSource
Hi @tuxdevelop, Also I would like to configure a separate database url that talks to a dedicated batch schema(spring_batch tables plus lightmin tables) which should be different from the application schema configured in application.properties file. How do I achieve that using @EnableEmbeddedSpringBatchLightminServer annotation?