Announcement Announcement Module
Collapse
No announcement yet.
Problems PropertyPlaceholderConfig Not Working Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems PropertyPlaceholderConfig Not Working

    Is anyone else experiencing this?

    When I add a CustomEditorConfigurer as a bean in my application context my PropertyPlaceholderConfigurer stops working.

    Any ideas?

    I am using 1.1.1

  • #2
    Further investigation.

    Here is the pertinent configuration.

    Code:
        <!-- Configurer that replaces $&#123;...&#125; placeholders with values from a properties file -->
        <!-- &#40;in this case, JDBC-related settings for the dataSource definition below&#41; -->
        <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="ignoreUnresolvablePlaceholders">
                <value>true</value>
            </property>
            <property name="ignoreResourceNotFound">
                <value>true</value>
            </property>
            <property name="locations">
                <list>
                    <!-- This is used when in application mode -->
                    <value>/app.properties</value>
                    <!-- This is used when in web-application mode -->
                    <value>/WEB-INF/app.properties</value>
                </list>
            </property>
        </bean>
    
        <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
            <property name="customEditors">
                <map>
                    <entry key="app.domain.TimePeriod">
                        <bean class="app.propertyeditors.TimePeriodEditor">
                            <property name="timePeriodDAO">
                                <ref bean="timePeriodDAO"/>
                            </property>
                        </bean>
                    </entry>
                </map>
            </property>
        </bean>
    When I try and run the application with this configuration the "PropertyPlaceholderConfigurer" does not work. However, when I comment out the "timePeriodDAO" property for the "TimePeriodEditor" then the "PropertyPlaceholderConfigurer" appears to work fine.

    Any ideas on why it won't let me set the DAO?

    Also, am I required to override initBinder in my SimpleFormController to register this CustomPropertyEditor?

    Comment


    • #3
      How do you define "stops working"? Is it a silent failure, or do you get any error? These two things should be completely unrelated. Where are you actually trying to replace values, btw? Can you reproduce this in a small test case?

      As for the initbinder question, yes, you need to bind this for the controller. What you are doing here is registering the property editor for the use the application context it is being defined in via the CustomEditorConfigurer.

      Comment


      • #4
        Re: Problems PropertyPlaceholderConfig Not Working

        Originally posted by cwidhelm
        Is anyone else experiencing this?

        When I add a CustomEditorConfigurer as a bean in my application context my PropertyPlaceholderConfigurer stops working.

        Any ideas?

        I am using 1.1.1
        I have no ideas what happens there but experienced the same issue. If I use the following code the variables are resolved.
        Code:
        PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer&#40;&#41;;
        cfg.setLocation&#40;"build.properties"&#41;;
        cfg.postProcessBeanFactory&#40;factory&#41;;
        If I use the following bean definition it doesn't work.
        Code:
        <bean id="propertyConfigurer" 
              class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
            <property name="location">
                <value>build.properties</value>
            </property>
        </bean>
        The only difference I see is the post processing call. What really bugs me is the error message. There is NONE, only the variables are not set.

        Can anybody explain this?

        Comment


        • #5
          Re: Problems PropertyPlaceholderConfig Not Working

          Originally posted by haug
          Originally posted by cwidhelm
          Is anyone else experiencing this?

          When I add a CustomEditorConfigurer as a bean in my application context my PropertyPlaceholderConfigurer stops working.

          Any ideas?

          I am using 1.1.1
          I have no ideas what happens there but experienced the same issue. If I use the following code the variables are resolved.
          Code:
          PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer&#40;&#41;;
          cfg.setLocation&#40;"build.properties"&#41;;
          cfg.postProcessBeanFactory&#40;factory&#41;;
          If I use the following bean definition it doesn't work.
          Code:
          <bean id="propertyConfigurer" 
                class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
              <property name="location">
                  <value>build.properties</value>
              </property>
          </bean>
          The only difference I see is the post processing call. What really bugs me is the error message. There is NONE, only the variables are not set.

          Can anybody explain this?
          Then it sounds as if you are using a bean faactory, and not an application context. As mentioned in the manual, only application contexts automatically apply bean factory post-processors.

          Comment

          Working...
          X