diff --git a/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobProcessorDiscovery.java b/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobProcessorDiscovery.java index c6e79bb18cb..9ec5565ff5e 100644 --- a/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobProcessorDiscovery.java +++ b/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobProcessorDiscovery.java @@ -49,11 +49,8 @@ public List> discoverJobProcessors() { for (Bean bean : beans) { Class beanClass = bean.getBeanClass(); - if (JobProcessor.class.isAssignableFrom(beanClass)) { - - // Validate that the bean is in the correct scope - validateScope(bean); - + if (JobProcessor.class.isAssignableFrom(beanClass) + && isValidateScope(bean)) { processors.add((Class) beanClass); Logger.debug(this, "Discovered JobProcessor: " + beanClass.getName()); } @@ -75,14 +72,20 @@ public List> discoverJobProcessors() { * Validates that the scope of the bean is correct for a JobProcessor. * * @param bean The bean to validate. + * @return True if the scope is valid, false otherwise. */ - private void validateScope(Bean bean) { + private boolean isValidateScope(Bean bean) { + Class scope = bean.getScope(); if (scope != Dependent.class) { - throw new DotRuntimeException( - "JobProcessor " + bean.getBeanClass().getName() + - " must use @Dependent scope, found: " + scope.getName()); + final String errorMessage = "JobProcessor " + bean.getBeanClass().getName() + + " must use @Dependent scope, found: " + scope.getName() + " scope. " + + "Won't be registered."; + Logger.error(this, errorMessage); + return false; } + + return true; } } \ No newline at end of file