start, count);
JobParameters jobParameters = null;
if (lastInstances.isEmpty()) {
throw new JobParametersNotFoundException(
"No job instance found for job=" + jobName);
}
while (!lastInstances.isEmpty()) {
for (JobInstance jobInstance : lastInstances) {
List<JobExecution> jobExecutions = jobExplorer
.getJobExecutions(jobInstance);
if (jobExecutions == null || jobExecutions.isEmpty()) {
continue;
}
JobExecution jobExecution = jobExecutions.get(jobExecutions
.size() - 1);
if (jobExecution.getStatus()
.isGreaterThan(BatchStatus.STOPPING)) {
jobParameters = jobExecution.getJobParameters();
break;
}
}
if (jobParameters != null) {
break;
}
start += count;
lastInstances = jobExplorer.getJobInstances(jobName, start, count);
}
if (jobParameters == null) {
throw new JobParametersNotFoundException(
"No failed or stopped execution found for job=" + jobName);
}
return jobParameters;
}