Log load bean exception (#6356)

* Log load bean exception

* Address review

* import BeansException

Co-authored-by: João Paraquetti <joao@scclouds.com.br>
This commit is contained in:
João Jandre 2022-05-19 00:04:03 -03:00 committed by GitHub
parent 5fdd4d211d
commit ffc914d846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,7 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.springframework.aop.framework.Advised;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext;
@ -72,8 +73,14 @@ public class ComponentContext implements ApplicationContextAware {
Map<String, ComponentMethodInterceptable> interceptableComponents = getApplicationContext().getBeansOfType(ComponentMethodInterceptable.class);
for (Map.Entry<String, ComponentMethodInterceptable> entry : interceptableComponents.entrySet()) {
Object bean = getTargetObject(entry.getValue());
beanFactory.configureBean(bean, entry.getKey());
try {
Object bean = getTargetObject(entry.getValue());
beanFactory.configureBean(bean, entry.getKey());
} catch (BeansException e){
s_logger.error(String.format("Could not load bean due to: [%s]. The service will be stopped. Please investigate the cause of the error or contact your support team.", e.getMessage()), e);
System.exit(1);
}
}
Map<String, ComponentLifecycle> lifecycleComponents = getApplicationContext().getBeansOfType(ComponentLifecycle.class);