Issue
We are using Spring 4.3.5 in our application. While we try to uplift the Spring to 5.3.7, we are not able to initialize beans(inside "beanRefFactory.xml") inside the below tag-
<context-param>
<param-name>locatorFactorySelector</param-name>
<param-value>/beanRefFactory.xml</param-value>
</context-param>
Upon searching we found that "locatorFactorySelector" or "LOCATOR_FACTORY_KEY_PARAM" have been deprecated in Spring 5.0.0.M5. Details can be found here.
Kindly suggest if there is any other way to initialize "beanRefFactory.xml". We are using XML based configuration.
PS: have already gone through the answers, but no help.
Solution
I solved this by creating a custom class BeanFactoryContextLoader.java which extends ContextLoaderListener.
public class BeanFactoryContextLoaderListener extends ContextLoaderListener {
private static Logger log = Logger.getLogger(BeanFactoryContextLoaderListener.class);
@Override
protected ApplicationContext loadParentContext(ServletContext servletContext) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("beanRefFactory.xml");
return ctx;
}
}
This worked for me. By default Spring return null for the method "loadParentContext". You need to override it. This might give you some insight.
Answered By - Subhranil Sengupta