开发者

Spring PropertyPlaceholderConfigurer not replacing placeholder

I want to pass the WSDL url for an internal web service into my Spring beans.xml dynamically, using a PropertyPlaceHolderConfigurer.

Here's the scenario:

My web application is deployed in WebLogic 10.3. The WSDL url is contained in a properties file that is located outside my application (directly under the corresponding domain folder, while my application is inside the autodeploy folder). I set the location of this properties file in my domain's setDomainEnv.cmd file like below:

set JAVA_PROPERTIES=%JAVA_PROPERTIES% %CLUSTER_PROPERTIES% -Dproperty.file.path.config=%DOMAIN_HOME%\Service.properties

This is what my Service.properties file contains:

Service.WSDL.PATH=http://localhost:8088/mockServiceSoap?WSDL

My Spring beans.xml configuration:----

<bean id="file.path" class="java.lang.System" factory-method="getProperty">
      <constructor-arg index="0"><value>property.file.path.config</value></constructor-arg>
</bean>

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
       <property name="location" ref="file.path"/> 
</bean>

<bean id="myServiceId" class="com.test.service.ServiceImpl">
    <property name="myServiceSoap">
    <ref bean="myService"/>
    </property>
</bean>

<bean id="myService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean"> 
   <property name="serviceInterface" value="com.test.service.ServiceSoap"/> 
   <property name="wsdlDocumentUrl" value="${Service.WSDL.PATH}"/>
</bean> 

I enabled DEBUG l开发者_如何学Goog specifically for PPC and this is what I saw in my application log:

INFO  org.springframework.beans.factory.config.PropertyPlaceholderConfigurer 178 - Loading properties file from URL [file:D:/bea10.3/user_projects/domains/my_domain/Service.properties]

So, it seems that although the Service.properties file is getting loaded by PPC, the ${Service.WSDL.PATH} is NOT getting replaced.

What am I doing wrong here?

Also, how can I find out if PPC tried replacing the value of the placeholder and with what value? I was hoping the log file would contain that info but there was nothing there.

Any help is appreciated.


I've figured out, that PropertyPlaceholderConfigurer needs to be declared first in the application Context file, otherwise there's no guarantee of the load order. It took me a few hours to realize this.

Try moving the "file.path" bean into the PropertyPlaceHolderConfigurer's location property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜