Hi everyone,
I need to resolve a strange issue with spring propertyplaceholder. I have a subclass of PropertyPlaceholderConfigurer in which i am setting the location of the properties file to load based on some request parameter. So i want this bean to be created dynamically based on each request. Below is the code:
And my spring configuration isCode:public class IntegrationPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer{ public IntegrationPropertyPlaceholderConfigurer() { ResourceLoader resourceLoader = new DefaultResourceLoader(); Resource resource; HttpServletRequest request=((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest(); if(request.getParameter("areavpath")!= null && request.getParameter("areavpath").contains("SFDC")){ resource= resourceLoader.getResource("classpath:com/vmware/cms/integration/properties/SFDC.properties"); super.setLocation(resource); // this.postProcessBeanFactory(context.getBeanFactory()); }else if(request.getParameter("areavpath")!= null && request.getParameter("areavpath").contains("MYVMWARE")){ resource= resourceLoader.getResource("classpath:com/vmware/cms/integration/properties/MyVMWare.properties"); super.setLocation(resource); // this.postProcessBeanFactory(context.getBeanFactory()); } } }
I have added a requestcontext listener in my web.xml for using request scoped beans. But when i start my server i still get the error:Code:<bean id="PropertyConfigurer" class="com.vmware.cms.integration.utility.IntegrationPropertyPlaceholderConfigurer" lazy-init="true" scope="request"> <aop:scoped-proxy /> </bean>
Also the bean is not getting created for each request. It is working like a singleton bean. Please help me out!!! Could not find resolution anywhere !!!Code:No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.![]()



Reply With Quote
