Announcement Announcement Module
Collapse
No announcement yet.
can't use PropertyPlaceholderConfigurer twice? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:
    /WEB-INF/classes/ssoClient.properties
    /WEB-INF/classes/authsum.hibernate.properties

    The 2 spring config files:
    /WEB-INF/classes/authsumContext.xml
    /WEB-INF/classes/authsumclient.xml

    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!

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

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

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

    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:/ssoClient.properties</value></property>
    </bean>







    Code:
    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(PropertyPlaceholderConfigurer.java:244)
    	at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
    	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:414)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:328)
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)

  • #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 %{}.
    http://www.springframework.org/docs/...lders(boolean)
    http://www.springframework.org/docs/...a.lang.String)

    Comment

    Working...
    X