Uploaded image for project: 'Spring Batch Admin'
  1. Spring Batch Admin
  2. BATCHADM-226

template "manager/steps/html/executions.ftl" causes error 500 in case of missing stepNames


    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0.0, 1.3.1
    • Fix Version/s: None
    • Component/s: Manager


      How to reproduce:

      1) create job configuration"testJob" with step "testStep" and trigger one job execution for this job.
      -> This will create a job execution id e.g. "123" and one step execution with step name "testStep".
      2) modify the same job configuration "testJob": remove step "testStep" and add new step "newTestStep"; then trigger one job execution for (modified) "testJob".
      -> This will create a job execution id e.g. "234" and one step execution with step name "newTestStep".

      Now accessing
      will cause a 500 error page:

      {{org.springframework.web.util.NestedServletException: Request processing failed; nested exception is freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
      ==> execution.id  [in template "manager/steps/html/executions.ftl" at line 34, column 47]
      FTL stack trace ("~" means nesting-related):
      	- Failed at: ${execution.id}  [in template "manager/steps/html/executions.ftl" at line 34, column 45]
      	- Reached through: #include body  [in template "layouts/html/standard.ftl" at line 36, column 16]

      This is because the template has two step execution entries - instead of one - for this job execution:

      • the "correct" step execution for "newTestStep" with all attributes set (e.g. execution.id)
      • an "old/incorrect" step execution for "testStep" with empty attributes

      The cause of the additional step is in method Collection<StepExecution> getStepExecutions(Long jobExecutionId) of class org.springframework.batch.admin.service.SimpleJobService:

      missingStepNames.addAll(stepExecutionDao.findStepNamesForJobExecution(jobName, "*:partition*"));
      for (String stepName : missingStepNames) {
      			StepExecution stepExecution = jobExecution.createStepExecution(stepName);

      findStepnamesForJobExecutions(jobName) is picking up the "old" stepName "testStep", because there is an old job execution for "testJob" and puts those step Name in the list missingStepNames. Also "newTestStep" is added to the list because of second job execution.

      Then the method queries the actual step names for (second) job execution id "234" - only one step "newTestStep" is found and removes it from missingStepNames.

      Finally the method creates an additional empty step execution where only status is set to unknown; no ids set!

      The method is returning two step executions for job execution "234", even job execution in fact has only one step execution.

      I guess this is a design issue, because "job executions" are not related to "job configurations" if I modify an existing "job configuration", which is only identified by name.

      Possible Fixes:
      1) No Fix; in case of modifying step names for a job configuration I must ensure to also change the job name to make it distinct.
      2) Fix SimpleJobService:getStepExecutions(): Why is this method creating additional step executions?
      3) Fix template "manager/steps/html/executions.ftl" to ignore execution steps in case of ${execution.id} == null.




            • Assignee:
              rmontag Rainer Montag
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: