Example usage for org.springframework.batch.core.launch NoSuchJobException printStackTrace

List of usage examples for org.springframework.batch.core.launch NoSuchJobException printStackTrace

Introduction

In this page you can find the example usage for org.springframework.batch.core.launch NoSuchJobException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:cn.cuizuoli.appranking.batch.tasklet.AppRankingJobTest.java

@Test
public void execute() {
    JobExecution jobExecution = null;/* w  ww. j ava  2s  .c  o  m*/
    try {
        JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
        Job job = jobRegistry.getJob("appRankingJob");
        JobParameters jobParameters = jobParametersBuilder
                .addString("date", DateTime.now().toString("yyyyMMddHHmmss")).toJobParameters();
        jobExecution = jobLauncher.run(job, jobParameters);
    } catch (NoSuchJobException e) {
        e.printStackTrace();
    } catch (JobExecutionAlreadyRunningException e) {
        e.printStackTrace();
    } catch (JobRestartException e) {
        e.printStackTrace();
    } catch (JobInstanceAlreadyCompleteException e) {
        e.printStackTrace();
    } catch (JobParametersInvalidException e) {
        e.printStackTrace();
    } finally {
        while (jobExecution.isRunning()) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }
        }
    }
}