Announcement Announcement Module
No announcement yet.
can't use PropertyPlaceholderConfigurer twice? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • can't use PropertyPlaceholderConfigurer twice?

    I am using spring 2.0.2

    I have 2 different spring configuration files that I load in my web.xml file. Each spring config file contains a PropertyPlaceholderConfigurer. My web app fails to load due to "Could not resolve placeholder' for a property loaded in the 2nd spring config file.

    The 2 property files:

    The 2 spring config files:

    If I reverse the order of the spring config files in my web.xml file, whichever properties loaded in the 2nd PropertyPlaceholderConfigurer are the ones that are not resolved.

    Can anyone think of a way to maintain the 2 different spring configuration files that each depend upon a different property file?

    Thanks for your help!

    <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/authsumContext.xml,/WEB-INF/classes/authsumclient.xml</param-value>

    The first spring file (authsumContext.xml) loads a property file called

    <bean id="placeholderConfig" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location" value="classpath:/"/>

    The second spring file (authsumclient.xml) loads a property file called ssoClient.xml

    I gave it a different bean name "placeholderConfig2" so that the bean id would be distinct across the entire spring application context.

    <bean id="placeholderConfig2" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location"><value>classpath:/</value></property>

    org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'hessianSSOService' defined in ServletContext resource [/WEB-INF/classes/authsumclient.xml]: Could not resolve placeholder 'serverName'
    	at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(
    	at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(

  • #2
    You can use two of them, but I think this might be related to 'ignoreUnresolvablePlaceholders'. By default this is false. Your first placeholder tries to resolve all placeholder values in all applicationContext files and therefore fails. If you set 'ignoreUnresolvablePlaceholders' to true, this should work. Likewise you could have a different prefix for each file, e.g. ${} and %{}.