Results 1 to 2 of 2

Thread: PropertyPlaceholderConfigurer not working in Spring3

  1. #1

    Default PropertyPlaceholderConfigurer not working in Spring3

    Spring: 3.0.0M2
    JDK: 1.6

    We have had a custom instance of PropertyPlaceholderConfigurer working
    since Spring 2.5.4 as follows. This does not seem to work with
    Spring 3.0.0M2.

    Code:
     package X;
     import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
     public class MyConfigurer extends PropertyPlaceholderConfigurer {   
        //...
     }
    Here is the usage of my property placeholder configurer:

    Code:
    // MyBeans.xml
    
     <bean id="propertyConfigurer"
    		class="X.MyConfigurer"
    		init-method="initializeBean"
    
    		 p:searchSystemEnvironment="true"
    		 p:systemPropertiesModeName="SYSTEM_PROPERTIES_MODE_FALLBACK"
    	 />
    	 
    	<bean id="SomeBean"
    		class="..."
    		 p:property="${my.custom.property}"
    	/>
    MyConfigurer is never invoked; instead, it directly invokes
    org.springframework.beans.factory.config.PropertyP laceholderConfigurer.processProperties,
    which fails to evaluate ${my.custom.property}:

    Code:
    org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'my.custom.property' defined in class path resource [MyBeans.xml]: Could not resolve placeholder 'my.custom.property'
    	at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:269)
    	at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
    	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:543)
    	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:518)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:358)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:254)
      //...
    Please help! Any suggestions appreciated!

    /U

  2. #2

    Default Resolved

    Sorry to followup on my own post - the problem occurred because
    another instance property placeholder configurer was being created
    that was silently overriding the existing instance.

    Is there a way to "boobytrap" instantiation of PropertyPlaceholderConfigurer
    so as to abort the context instead of allowing it to continue with the
    spurious instance of the placeholder configurer?

    I mean, since the context will use only the latest instance of the
    PropertyPlaceholderConfigurer, is there a way to query the
    container and find the identity of the placeholder configurer
    currently in use?

    Regards

    /U

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •