Better error handling in case a scheduler job name listed in database

cannot be found in the code (instead of the NPE currently happenig in
such cases)
 
Signed-off-by: Michael Vorburger <mike@vorburger.ch>
This commit is contained in:
Michael Vorburger
2014-08-14 23:05:10 +02:00
parent 9893563865
commit df4a070123
@@ -302,6 +302,9 @@ public class JobRegisterServiceImpl implements JobRegisterService {
private JobDetail createJobDetail(final ScheduledJobDetail scheduledJobDetail) throws Exception {
final MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant();
final ClassMethodNamesPair jobDetails = CronMethodParser.findTargetMethodDetails(scheduledJobDetail.getJobName());
if (jobDetails == null) { throw new IllegalArgumentException(
"Code has no @CronTarget with this job name (@see JobName); seems like DB/code are not in line: "
+ scheduledJobDetail.getJobName()); }
final Object targetObject = getBeanObject(Class.forName(jobDetails.className));
final MethodInvokingJobDetailFactoryBean jobDetailFactoryBean = new MethodInvokingJobDetailFactoryBean();
jobDetailFactoryBean.setName(scheduledJobDetail.getJobName() + "JobDetail" + tenant.getId());