org.springframework.batch.core.launch.NoSuchJobInstanceException Java Examples

The following examples show how to use org.springframework.batch.core.launch.NoSuchJobInstanceException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResponseExceptionHandler.java    From spring-batch-rest with Apache License 2.0 6 votes vote down vote up
@ExceptionHandler(BatchRuntimeException.class)
protected ResponseEntity<Object> handleBatchRuntimeException(BatchRuntimeException e, WebRequest request) {
    log.error("Request {} failed with {}", request, e);
    Throwable cause = e.getCause();
    HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR;
    if (cause instanceof DuplicateJobException
            || cause instanceof JobExecutionAlreadyRunningException
            || cause instanceof JobInstanceAlreadyCompleteException)
        status = HttpStatus.CONFLICT;
    else if (cause instanceof JobParametersInvalidException
        || cause instanceof JobParametersNotFoundException)
        status = HttpStatus.BAD_REQUEST;
    else if (cause instanceof NoSuchJobException
        || cause instanceof NoSuchJobExecutionException
        || cause instanceof NoSuchJobInstanceException)
        status = HttpStatus.NOT_FOUND;

    ApiError apiError = new ApiError(status.toString(), cause.getMessage(), cause.getClass().getSimpleName(), e.getMessage());
    return handleExceptionInternal(e, apiError, new HttpHeaders(), status, request);
}
 
Example #2
Source File: RestControllerAdvice.java    From spring-cloud-dashboard with Apache License 2.0 6 votes vote down vote up
/**
 * Log the exception message at warn level and stack trace as trace level.
 * Return response status HttpStatus.NOT_FOUND
 */
@ExceptionHandler({NoSuchAppRegistrationException.class,
		NoSuchTaskDefinitionException.class,
		NoSuchTaskExecutionException.class,
		NoSuchJobExecutionException.class,
		NoSuchJobInstanceException.class,
		NoSuchJobException.class,
		NoSuchStepExecutionException.class,
		MetricsMvcEndpoint.NoSuchMetricException.class})
@ResponseStatus(HttpStatus.NOT_FOUND)
@ResponseBody
public VndErrors onNotFoundException(Exception e) {
	String logref = logWarnLevelExceptionMessage(e);
	if (logger.isTraceEnabled()) {
		logTraceLevelStrackTrace(e);
	}
	String msg = getExceptionMessage(e);
	return new VndErrors(logref, msg);
}
 
Example #3
Source File: RestControllerAdvice.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
/**
 * Log the exception message at warn level and stack trace as trace level. Return
 * response status HttpStatus.NOT_FOUND
 *
 * @param e one of the exceptions, {@link NoSuchAuditRecordException},
 * {@link NoSuchStreamDefinitionException},
 * {@link NoSuchAppRegistrationException}, {@link NoSuchTaskDefinitionException},
 * {@link NoSuchTaskExecutionException}, {@link NoSuchJobExecutionException},
 * {@link NoSuchJobInstanceException}, {@link NoSuchJobException},
 * {@link NoSuchStepExecutionException},
 * {@link NoSuchAppException}, or
 * {@link NoSuchAppInstanceException}
 * @return the error response in JSON format with media type
 * application/vnd.error+json
 */
@ExceptionHandler({ NoSuchAuditRecordException.class,
		NoSuchStreamDefinitionException.class, NoSuchAppRegistrationException.class,
		NoSuchTaskDefinitionException.class, NoSuchTaskExecutionException.class, NoSuchJobExecutionException.class,
		NoSuchJobInstanceException.class, NoSuchJobException.class, NoSuchStepExecutionException.class,
		NoSuchTaskBatchException.class, NoSuchAppException.class, NoSuchAppInstanceException.class,
		NoSuchScheduleException.class })
@ResponseStatus(HttpStatus.NOT_FOUND)
@ResponseBody
public VndErrors onNotFoundException(Exception e) {
	String logref = logWarnLevelExceptionMessage(e);
	if (logger.isTraceEnabled()) {
		logTraceLevelStrackTrace(e);
	}
	String msg = getExceptionMessage(e);
	return new VndErrors(logref, msg);
}
 
Example #4
Source File: SimpleJobService.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Override
public JobInstance getJobInstance(long jobInstanceId) throws NoSuchJobInstanceException {
	JobInstance jobInstance = jobInstanceDao.getJobInstance(jobInstanceId);
	if (jobInstance == null) {
		throw new NoSuchJobInstanceException("JobInstance with id=" + jobInstanceId + " does not exist");
	}
	return jobInstance;
}
 
Example #5
Source File: DefaultTaskJobService.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Override
public JobInstanceExecutions getJobInstance(long id) throws NoSuchJobInstanceException, NoSuchJobException {
	return getJobInstanceExecution(jobService.getJobInstance(id));
}
 
Example #6
Source File: JobInstanceController.java    From spring-cloud-dataflow with Apache License 2.0 3 votes vote down vote up
/**
 * View the details of a single task instance, specified by id.
 *
 * @param id the id of the requested {@link JobInstance}
 * @return the {@link JobInstance}
 * @throws NoSuchJobInstanceException if job instance for the id does not exist.
 * @throws NoSuchJobException if the job for the job instance does not exist.
 */
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public JobInstanceResource view(@PathVariable("id") long id) throws NoSuchJobInstanceException, NoSuchJobException {
	JobInstanceExecutions jobInstance = taskJobService.getJobInstance(id);
	return jobAssembler.toModel(jobInstance);
}
 
Example #7
Source File: TaskJobService.java    From spring-cloud-dataflow with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieves a {@link JobInstance} from the JobRepository and matches it with the
 * associated {@link JobExecution}s.
 *
 * @param id the id of the {@link JobInstance}
 * @return the {@link JobInstanceExecutions} associated with the id.
 * @throws NoSuchJobInstanceException if job instance id does not exist.
 * @throws NoSuchJobException if the job for the job instance does not exist.
 */
JobInstanceExecutions getJobInstance(long id) throws NoSuchJobInstanceException, NoSuchJobException;
 
Example #8
Source File: JobService.java    From spring-cloud-dataflow with Apache License 2.0 2 votes vote down vote up
/**
 * Get a {@link JobInstance job instance} by id.
 * 
 * @param jobInstanceId the id of the instance
 * @return a {@link JobInstance job instance}
 * @throws NoSuchJobInstanceException thrown if the job instance specified does not exist
 */
JobInstance getJobInstance(long jobInstanceId) throws NoSuchJobInstanceException;