1

I’m using Spring 3.2.11.RELEASE with Maven 3.3. I have this defined in my application context file …

<bean id="localPropertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
     <property name="locations">
        <list>
            <value>classpath:quickbase.properties</value>
        </list>
        </property>
</bean> 
…
<bean id=“myClient" class="org.mainco.subco.mysystem.MyClient">
    <constructor-arg index="0" type="String" value="${quickbase.username}" />
    <constructor-arg index="1" type="String" value="${quickbase.password}" />
    <constructor-arg index="2" type="String" value="${quickbase.url}" />
</bean>

but when I run my test, I get the below error

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'myClient' defined in class path resource [META-INF/spring/applicationContext-orders.xml]: Could not resolve placeholder 'quickbase.username' in string value "${quickbase.username}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'quickbase.username' in string value "${quickbase.username}"

This is baffling me because in my target/classes directory, I can see a file, “quickbase.properties,” that has the “quickbase.username” defined. I can’t figure out what else I need to check.

Dave
  • 15,639
  • 133
  • 442
  • 830

2 Answers2

9

I received similar error today. I resolved it by adding a little space between the dollar and first brace {. I believe java runtime is trying to resolve an unintended placeholder. Following is the example:

<bean id=“myClient" class="org.mainco.subco.mysystem.MyClient">
    <constructor-arg index="0" type="String" value="$ {quickbase.username}" />
    <constructor-arg index="1" type="String" value="$ {quickbase.password}" />
    <constructor-arg index="2" type="String" value="$ {quickbase.url}" />
</bean>
Chaos Legion
  • 2,730
  • 1
  • 15
  • 14
0

Having more than one org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in your application could be a reason for this.

Have a look at this: Could not resolve Spring property placeholder

Might be the answer you are looking for..

Community
  • 1
  • 1
ritesh.garg
  • 3,725
  • 1
  • 15
  • 14