diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/BatchConfigurationException.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/BatchConfigurationException.java new file mode 100644 index 000000000..6b1da62a6 --- /dev/null +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/BatchConfigurationException.java @@ -0,0 +1,34 @@ +/* + * Copyright 2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.batch.core.configuration; + +/** + * Represents an error has occured in the configuration of base batch + * infrastructure (creation of a {@link org.springframework.batch.core.repository.JobRepository} + * for example. + * + * @author Michael Minella + * @since 2.2.6 + */ +public class BatchConfigurationException extends RuntimeException { + + /** + * @param t an exception to be wrapped + */ + public BatchConfigurationException(Throwable t) { + super(t); + } +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java index 8ad30f99d..0995c9eec 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java @@ -18,6 +18,7 @@ package org.springframework.batch.core.configuration.annotation; import javax.annotation.PostConstruct; import javax.sql.DataSource; +import org.springframework.batch.core.configuration.BatchConfigurationException; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.support.SimpleJobLauncher; import org.springframework.batch.core.repository.JobRepository; @@ -63,9 +64,13 @@ public class DefaultBatchConfigurer implements BatchConfigurer { } @PostConstruct - public void initialize() throws Exception { - this.jobRepository = createJobRepository(); - this.jobLauncher = createJobLauncher(); + public void initialize() throws BatchConfigurationException { + try { + this.jobRepository = createJobRepository(); + this.jobLauncher = createJobLauncher(); + } catch (Exception e) { + throw new BatchConfigurationException(e); + } } private JobLauncher createJobLauncher() throws Exception {