New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stopping a job from a different JVM throws a NoSuchJobException [BATCH-2667] #937
Comments
Mahmoud Ben Hassine commented Hi Yassine, Thank you for pointing out this issue! We are working on this issue and we will let you know when it is fixed. Kr |
Mahmoud Ben Hassine commented @Ouerghi Yassine The NoSuchJobException is actually not thrown to client code, the stack trace is a warning logging the root exception. Using the code you shared to stop the job from a different JVM, since the job is not defined in the application context (not registered in the JobRegistry) of the second project, you are getting this warning. The job is found in the shared database (hence it is correctly stopped) but not in the JobRegistry of the second project. The same happens when trying to resume the job from the second project. |
Ouerghi Yassine commented
|
Mahmoud Ben Hassine commented You don't have to register the job manually. You can autowire a JobRegistry in your configuration class and add a bean of type JobRegistryBeanPostProcessor or AutomaticJobRegistrar (more details on that here) and the job will be registered automatically. I think a possible way to approach your use case is to have the job definition in a separate jar and share it between both projects, something like:
|
Mahmoud Ben Hassine commented Hi @Ouerghi Yassine We are going to update the warning to a more explicit message saying that the job cannot be found in the job registry (to not be confused with the database). Kr |
Ouerghi Yassine commented Hello, |
Mahmoud Ben Hassine commented Just to be clear, we are not fixing anything here. Spring Batch is working as expected, it does not find the job so it logs a warning about it. We cannot re-register jobs from database entries (this is just impossible since only the job name resides in the database, not its definition). |
Ouerghi Yassine opened BATCH-2667 and commented
I have 2 projects:
Both projects points to the same database,
when trying to stop a job, using the JobExecutionId, from the 2nd project, I get a NoSuchJobException, even though the job is successfully stopped.
Here is the complete stacktrace:
The code for running/stoping jobs:
Im not sure if this is related or not, but resuming stopped jobs does not seem to work either, and getting same exception: NoSuchJobException
Affects: 3.0.8
Referenced from: pull request #566, and commits 7b3d438, d81ab76
Backported to: 3.0.9
The text was updated successfully, but these errors were encountered: