Announcement Announcement Module
Collapse
No announcement yet.
Problem with PropertyPlaceholderConfigurer. Not replacing property values Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with PropertyPlaceholderConfigurer. Not replacing property values

    Hello All,

    I am facing problem with PropertyPlaceholderConfigurer.

    I have declared my PropertyPlaceholderConfigurer as follows

    ====================================

    <!-- property placeholder post-processor -->
    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer" lazy-init="false">
    <property name="location" value="classpath:/odsaquafields.properties"/>
    </bean>


    ====================================

    My Bean refererring the properties as follows
    ====================================

    <bean id="dataDefinitionReader" class="com.csfb.odsaqua.xml.DataDefinitionReader"
    init-method="loadDataDefinitions" singleton="true">
    <property name="parserClass">
    <value>com.csfb.odsaqua.xml.ODSAquaXMLDataDefiniti onParser</value>
    </property>
    <property name="dataDefinitionConfig">
    <value>${odsaquafields.dataDefinitionConfigPath}</value>
    </property>
    <property name="validating">
    <value>false</value>
    </property>
    </bean>

    ==================================================

    But when I see the output of dataDefinitionConfig. It is showing as ${odsaquafields.dataDefinitionConfigPath}.

    I have seen in the logs, It has been shown as :${odsaquafields.dataDefinitionConfigPath}

    Please help me where am I wrong.

    Regards,
    Shiv

  • #2
    you should notice the two isuses in your code

    hi,


    try {
    factory = new XmlBeanFactory(new ClassPathResource(
    "clr-appcontext.xml"));
    PropertyPlaceholderConfigurer ppc = (PropertyPlaceholderConfigurer) factory
    .getBean("placeholderConfig");
    ppc.postProcessBeanFactory(factory);

    } catch (Exception e) {
    log.fatal("load spring application context config file"
    + " 'clr-appcontext.xml' error...\n" + e.getMessage());
    }


    other, define 'odsaquafields.dataDefinitionConfigPath=???' in your properties file:odsaquafields.properties.

    Comment


    • #3
      Thanks for help

      Thanks for help xmh,

      Problem has solved now.

      Actually In my framework I was instantiating XmlBeanFactory 2 times.

      beanFactory = new XmlBeanFactory(new ClassPathResource(resourceName)) 2 times;

      When I use the ApplicationContextAware instead of using XmlBeanFactory every time to get bean reference, then problem got solved.

      Regards,
      Shiv

      Comment


      • #4
        Distinction between ApplicationContexts and Bean Factories

        Just to make things clear:
        One of the extended functionality that ApplicationContext's have against beanFactories is that it automatically recognizes bean post processors (classes that implement BeanPostProcessor) and bean factory post processors (classes that implement BeanFactoryPostProcessor). Since PropertyPlaceholderConfigurer is a BeanPostprocessor it will be automatically detected by an ApplicationContext and executed. In a simple BeanFactory this is not done automatically and must be done manually. More info at:
        http://static.springframework.org/sp...postprocessors
        http://static.springframework.org/sp...-extension-bpp

        Comment

        Working...
        X