Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

org.springframework.batch.core.repository.JobExecutionAlreadyRunningException

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following xml configured from the Spring Batch examples to run every 10 seconds but I get an error while starting up. I also have logs configured at InfiniteLoopReader and InfiniteLoopWriter but it never hits those classes and yes it does make entries into the batch table.
How do I reconfigure this ?


 
Ranch Hand
Posts: 607
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to pass in different parameters at start-up for the job to run.

If the job was previously launched with teh same JobParameters and completed successfully, then it is an error to restart it. An ad-hoc request needs to be distinguished from previous runs by adding a unique job parameter. In either case a new JobExecution is created and stored to monitor this execution of the JobInstance.

 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sam Mercs wrote:You need to pass in different parameters at start-up for the job to run.



Is there an example you could point me to or could you post a quick code snippet on what parameter needs to be passed. If it needs to be unique can I just pass the time in milliseconds ? Not sure how it can be done though ...
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have not mentioned how you are running the job, are you trying to run is as a Junit test? are you running it from the command line? do you have it scheduled to run?

In all case, you need to pass in job parameters, you can get all the details - http://static.springsource.org/spring-batch/reference/html/configureJob.html - 4.4. Running a Job in this section of the document.

Here is the gist,

If your using the command like job runner (shell script)

dateParam=date '+%m%d%y_%H%M%S'
java CommandLineJobRunner JOB_CONFIG.xml JOB_NAME timestamp=$dateParam

If you using Junit test & JobLauncherTestUtils, from the Javadoc...

It should be noted that using any of the methods that don't contain JobParameters in their signature, will result in one being created with the current system time as a parameter. This will ensure restartability when no parameters are provided.


If you are passing in param you need to add a unique param...



 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am running the job using quartz. The intention is to trigger some service calls within the ear to do some plumbing tasks every hour.

I wasn't sure on how to pass the job parameters in my case but when I increased the time gap between the tasks and also removed the Thread sleep in the samples, it wasn't spitting out JobExecutionAlreadyRunningException.

And it now triggers the job properly
com.test.JobLauncherDetails executeInternal Quartz trigger firing with Spring Batch jobName=footballJob
com.test.JobLauncherDetails executeInternal Quartz trigger firing with Spring Batch jobName=footballJob
com.test.JobLauncherDetails executeInternal Quartz trigger firing with Spring Batch jobName=footballJob
......

But now I don't see any entries in the Spring batch table, it doesn't seem to hit the reader/writer classes even though it isn't throwing any exceptions.

One more question, I was able to trigger my batch using Quarts example @ Quartz example. I keep hearing that Spring Batch is the ideal way to do this but can someone explain why using Batch is a better bet than using quartz in my scenario.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does your datasource and transactionManager beans refer to. Could you add the configuration for those. If they are configured correctly, it should write to the database ...
 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here goes...
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
ScroogeXHTML 8.7 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/730700/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic