Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clearer error message when JobLauncher not defined in CommandLineJobRunner [BATCH-1199] #2381

spring-issuemaster opened this issue Apr 7, 2009 · 1 comment


Copy link

@spring-issuemaster spring-issuemaster commented Apr 7, 2009

Michel Zanini opened BATCH-1199 and commented

In most of the jobs I think SimpleJobLaucher will be used, like this:

<beans:bean class="">
<beans:property name="jobRepository" ref="jobRepository" />

This code is easy to forget (if so causes NullPointerException at CommandLineJobRunner), and difficult to explain why is necessary for a beginner.

My idea is to turn this optional just for who wants to customize the JobLauncher. I made a simple change in CommandLineJobRunner to do that. (patch attached)

I add a setter for a JobRepository in CommandLineJobRunner. This way, when autowire by type is applied the property will be set. After the autowire I add this code:

if (launcher == null) {
if (jobRepository == null) {
//improve exception handling
throw new IllegalArgumentException("JobLauncher and JobRepository not defined");
launcher = new SimpleJobLauncher();

If the user defines a JobLauncher this will be used. If the user just defines a JobRepository then we create a SimpleJobLauncher for this, automatically. Most of the users doesn't have to know about JobLauncher interface anymore.

Affects: 2.0.0.RC3


Referenced from: commits 47d4afd


This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 8, 2009

Dave Syer commented

I would prefer to just provide a clear error message (done). Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.