Skip to content

Conversation

@imod
Copy link

@imod imod commented Dec 27, 2020

fix lightmin-jpa-application:

  • add @EnableLightminJdbcConfigurationRepository
  • fix path to H2 init script

@tuxdevelop
Copy link
Owner

Hi @imod
thank you for the PR. I took your changes and fixed two more things in the JPA demo.
I already pushed it into master.

Thanks and Greetings

@tuxdevelop tuxdevelop closed this Jan 5, 2021
@imod
Copy link
Author

imod commented Jan 12, 2021

@tuxdevelop please allow me a question: is it really required/expected one has to configure two datasources to get lightmin working with JPA? https://github.com/tuxdevelop/spring-batch-lightmin-samples/blob/master/lightmin-jpa-application/src/main/java/org/tuxdevelop/sample/jpa/batch/configuration/ApplicationConfiguration.java
This feels odd and requires additional configuration to keep the two in sync (we store all data in the same database, spring batch, lightmin and application data).

@tuxdevelop
Copy link
Owner

tuxdevelop commented Jan 12, 2021

Hi @imod,
it is not required to have two datasources. The issue is this is not lightmin, it is Spring Batch.

I adapted the demo in the branch:

https://github.com/tuxdevelop/spring-batch-lightmin-samples/blob/features/jpa_single_datasource/lightmin-jpa-application/src/main/java/org/tuxdevelop/sample/jpa/batch/configuration/ApplicationConfiguration.java

In order to make it work, the spring batch repo must be a map

spring:
  batch:
    lightmin:
      batch:
        repository-type: map

If you change this, Spring Batch and JPA are conflicting using the same datasource.

Side note:

In my personal opinion, it just feels natural to have two datasources with different configurations (also two databases in the best scenario) to separate the runtime/configuration data (Spring Batch/Lightmin) and the business data (JPA entities).

@imod
Copy link
Author

imod commented Jan 12, 2021

many thanks! don't know why you think Spring Batch is the issue - before we used lightmin we never had to configure two datasoruces to make it work.
Anyway, the map also does not work for me, I get this when I click on the Batch Jobs Link in Lightmin for every job I have configured:

org.springframework.batch.core.launch.NoSuchJobException: No job instances for job name skillSuggestionIndexVersionUpdateJob were found
	at org.springframework.batch.core.repository.dao.MapJobInstanceDao.getJobInstanceCount(MapJobInstanceDao.java:140)
	at org.springframework.batch.core.explore.support.SimpleJobExplorer.getJobInstanceCount(SimpleJobExplorer.java:221)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

I am able to reproduce this with your sample application if I disable automatic job execution:

# no automatic starting of batch jobs at startup
spring.batch.job.enabled=false 

and when I start a job via Lightmin Launcher, I get this:

2021-01-12 13:41:58.813  INFO 18479 --- [cTaskExecutor-2] o.s.b.c.l.support.SimpleJobLauncher      : Job: [SimpleJob: [name=profileIndexVersionUpdateJob]] launched with the following parameters: [{DATE_INCREMENTER=1610458918793}]
2021-01-12 13:41:58.813  INFO 18479 --- [nio-9090-exec-5] .c.l.OnJobExecutionFinishedEventListener : profileIndexVersionUpdateJob, Status: STARTING, Exit: UNKNOWN
2021-01-12 13:41:58.822  INFO 18479 --- [cTaskExecutor-2] o.s.batch.core.job.SimpleStepHandler     : Executing step: [createProfileIndexStep]
2021-01-12 13:41:59.263  INFO 18479 --- [cTaskExecutor-2] o.s.batch.core.step.AbstractStep         : Step: [createProfileIndexStep] executed in 438ms
2021-01-12 13:41:59.324  INFO 18479 --- [cTaskExecutor-2] o.s.b.c.l.support.SimpleJobLauncher      : No TaskExecutor has been set, defaulting to synchronous executor.
2021-01-12 13:41:59.333  INFO 18479 --- [cTaskExecutor-2] o.s.batch.core.job.SimpleStepHandler     : Executing step: [profileIndexVersionUpdateJob_reindexStep]
2021-01-12 13:41:59.337 ERROR 18479 --- [cTaskExecutor-2] o.s.batch.core.step.AbstractStep         : Encountered an error executing step profileIndexVersionUpdateJob_reindexStep in job profileIndexVersionUpdateJob

org.springframework.transaction.TransactionSuspensionNotSupportedException: Transaction manager [org.springframework.batch.support.transaction.ResourcelessTransactionManager] does not support transaction suspension
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.doSuspend(AbstractPlatformTransactionManager.java:1120)
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.suspend(AbstractPlatformTransactionManager.java:595)

@tuxdevelop
Copy link
Owner

Hi @imod,
I looked into the current Spring Batch Configurer implementations and they are providing a JPA specific one.
I will create a ticket to adapt the Lightmin implementations and provide an adaption for JPA as well.

I will let you, when a first draft is available.

@imod
Copy link
Author

imod commented Jan 12, 2021

@tuxdevelop awesome 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants