Announcement Announcement Module
No announcement yet.
<util:properties and @Value not working Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • <util:properties and @Value not working


    I am calling a SOAP web service using Spring's WebServiceGatewaySupport.

    It works fine, but I now need to externalize the endpoint ipAddress. Since the
    endpoint is used in several methods in the class, I've defined the endpoint as
    a class variable.

    I've defined a text property file, utilroperties in applicationContext.xml, and @Value in the class.
    When I don't reference the value in my class, the app starts fine so I know Spring is finding
    my properties file and correlating it to the @Value.

    However, I get a 'could not resolve placeholder' error with @Value("${myProp.ipAddress}") syntax.
    With @Value("${myProp['ipAddress']}") syntax I get a null value in the ipAddress field.

    I've tried both the static $ and dynamic # tags, to no avail. Is it possible that Spring won't
    retrieve the value until after the class is instantiated ? If so, how do I get an externalized
    endpoint ipAddress into my class ?

    The code is below.

    Please help !!!


    <util:properties id="myProp" location="/WEB-INF/properties/myProperties"/>
    property file

    @Value bits in the class

    public class MyClass extends WebServiceGatewaySupport implements IMyClass
            @Value("${myProp.ipAddress}") // (or @Value("${myProp['ipAddress']}")
    	public void setIpAddress(String ipAddress)
    		this.ipAddress = ipAddress;
    	MySoapProxy mySoapProxy = new MySoapProxy(ipAddress + "/MySoapService?wsdl");
    Last edited by Slidewayz; Oct 19th, 2011, 11:34 PM.

  • #2
    OK, I cracked it.

    I set the value of the endpoint url within a @PostConstruct method. Therefore, the reason
    why this wasn't working was because the property isn't set by Spring until after all the
    properties in the class are instantiated.