Announcement Announcement Module
No announcement yet.
How to specify job parameters for endOfDayJob? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to specify job parameters for endOfDayJob?


    I've performed basic endOfDayJob Setup and I'm able to run this using my batch-test and it works as expected.

    Now, I've added Quartz scheduler to run it every end of day. however, it throws the exceptions like
    org.springframework.batch.core.repository.JobExecutionAlreadyRunningException: A job execution for this job is already running: JobInstance: id=172, version=0, JobParameters=[{}], Job=[loadFile]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    	at java.lang.reflect.Method.invoke(
    each job execution should be specific to the day it is being executed. I know it is controlled by JobParameters but where and how do I specify it?

  • #2
    you specify job parameters when launching the job, with the, JobParameters) method.


    • #3
      Thanks for the reply.

      But, where in spring configuration do you specify and how?

      is it going to be in <job /> or somewhere else? any examples please!


      • #4
        nowhere in the configuration: this a Java API. It depends on the way you launch your jobs. How do you launch the job?


        • #5
          The reported exception is expected when a job is run with same parameters. In my case it will be successful only once because there are no job parameters specified [see my original post].

          I'm launching the job using quartz as shown in spring batch reference

          <bean id="jobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
              <property name="jobClass" value="org.springframework.batch.sample.quartz.JobLauncherDetails" />
              <property name="group" value="quartz-batch" />
              <property name="jobDataAsMap">
                      <entry key="jobName" value="footballJob"/>
                      <entry key="jobLocator" value-ref="jobRegistry"/>
                      <entry key="jobLauncher" value-ref="jobLauncher"/>
          <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
            <property name="triggers">
              <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
                <property name="jobDetail" ref="jobDetail" />
                <property name="cronExpression" value="0/10 * * * * ?" />


          • #6
            the sample doesn't provide any job parameter, that's why the first launch works and you get an JobExecutionAlreadyRunningException then. You should take a look at the JobLauncherDetails code and at the Spring/Quartz integration to see how to specify job parameters (with Quartz's job map). You can also choose Spring Scheduling (which is simpler than Quartz, but requires Spring 3.0).


            • #7
              Thank you. As of now, I'm adding a job parameter from JobLauncherDetails.