1

Have the context spring conf like this, I have 2 property-placeholder in my context.

<?xml version="1.0" encoding="UTF-8"?>
<beans>
    <context:annotation-config/>
    <context:component-scan base-package="com.xxx.app.xxx"/>

    <context:property-placeholder location="classpath:em-management.properties"/>
    <context:property-placeholder location="file:///opt/ass/swp/conf/platform.properties"/>

</beans>

When I run the code, met this error:

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CMClient': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.xxxx.app.xxxx.xx.client.CMClient.washost; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'com.ibm.CORBA.securityServerHost' in string value "${com.ibm.CORBA.securityServerHost}"

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.xxxx.app.xxx.xxx.client.CMClient.washost; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'com.ibm.CORBA.securityServerHost' in string value "${com.ibm.CORBA.securityServerHost}"

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'com.ibm.CORBA.securityServerHost' in string value "${com.ibm.CORBA.securityServerHost}"

how to solve this issue?

4
  • Do you have defined the string com.ibm.CORBA.securityServerHost in one of your property files? Commented Jun 3, 2015 at 9:48
  • Don't use multiple <context:property-placeholder /> elements, use a single one. location takes a , separated value, so use location="classpath:em-management.properties,file:///opt/ass/swp/conf/platform.properties" instead of 2 elements. Commented Jun 3, 2015 at 9:50
  • @Jens, yes, it's existing. Commented Jun 3, 2015 at 13:45
  • @Deinum, I will try your approach. Commented Jun 3, 2015 at 13:45

2 Answers 2

2

I found the solution for this particular problem,just append ignore-unresolvable="true" to each line.

<context:property-placeholder location="classpath:em-management.properties" ignore-unresolvable="true"/>
<context:property-placeholder location="file:///opt/ass/swp/conf/platform.properties" ignore-unresolvable="true"/>
Sign up to request clarification or add additional context in comments.

1 Comment

That isn't really a solution, the actual solution is to not use multiple placeholder <context:property-placeholder /> elements.
1

Don't use multiple <context:property-placeholder/> tags, refer below code for the same and also make sure you have a key "com.ibm.CORBA.securityServerHost" with a value in either of your property file.

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
   <property name="location">
      <list>
         <value>classpath:em-management.properties</value>
         <value>file:///opt/ass/swp/conf/platform.properties</value>
      </list>
   </property>
   <property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.