0

After a migration of the spring framework to 4.2.8 (since version 4.1.6), I can’t load the configuration via custom PropertyPlaceholder.

<bean id="customPlaceHolderConfigurer" class="xxx.CustomPlaceHolderConfigurer">
    <property name="order" value="#{T(org.springframework.core.Ordered).HIGHEST_PRECEDENCE + 10}" />
    <property name="ignoreUnresolvablePlaceholders" value="true" />
</bean>

<jaxws:client id="wsBusinessService" address="${pf:WS_URL}/soap/ws" serviceClass="xxx.WSBusinessService" />

And CustomPlaceholder

public class CustomPlaceHolderConfigurer extends PropertyPlaceholderConfigurer {

    private static final Logger LOGGER = LoggerFactory.getLogger(CustomPlaceHolderConfigurer.class);

    @Override
    protected String resolvePlaceholder(final String pPlaceholder, final Properties pProps) {
        String value = null;
        if (pPlaceholder != null) {
            if (CIStringUtils.startsWith(pPlaceholder, "pf")) {
                String propertyKey = StringUtils.substring(pPlaceholder, 3);
                if (propertyKey.contains(":")) {
                    String defaultValue = StringUtils.substringAfter(propertyKey, ":");
                    String newKey = StringUtils.substringBefore(propertyKey, ":");
                    value = Plateforme.getProperty(newKey, defaultValue);
                } else {
                    value = Plateforme.getProperty(propertyKey);
                }
            }
        }
        LOGGER.debug("placeholder '{}' resolved to '{}'", pPlaceholder, value);
        return value;
    }

}

When I start the application, I get the following log:

2016-12-13T15:52:12,448 [localhost-startStop-2] DEBUG CustomPlaceHolderConfigurer - placeholder 'pf:WS_URL' resolved to 'services.com'

but an exception was throwed by jaxws because the property was not replaced : « Could not find conduit initiator for address: ${pf:WS_URL}/soap/ws and transport: http://schemas.xmlsoap.org/soap/http »

I understood that the load order of the configuration was changed to spring 4.2.x, but I was unable to operate even by changing the order. (https://github.com/spring-projects/spring-framework/wiki/Migrating-to-Spring-Framework-4.x)

Spring Framework 4.2 comes with significant fine-tuning in configuration class processing. There may be subtle differences in the order of registration compared to 4.1; however, those are considered fixes of behavior that wasn't well-defined previously. If you are relying on a specific order, e.g. for overriding beans by name, please consider using 4.2's new facilities, in particular @Order annotations on config classes.

I tried :

#{T(org.springframework.core.Ordered).HIGHEST_PRECEDENCE + 10} #{T(org.springframework.core.Ordered).HIGHEST_PRECEDENCE} -1 1

Has anyone encountered this problem?

Thanks

  • Can you please paste the exception trace – Pradeep Dec 13 '16 at 14:01
  • I don't have an exception. Just the property wasn't replaced. The address variables equals _http://services.com/soap/ws_ in Spring 4.1.6, but in spring 4.2.x, adress equals _${pf:WS_URL}/soap/ws_ – Lucas Pouzac Dec 13 '16 at 14:26
  • Placeholder resolution in namespaces isn't done by Springs `PropertyPlaceholderConfigurer` or `PropertySourcesPlaceholderConfigurer` support has to be in the namespace itself. Next to that `${pf:WS_URL}` would try to resolve a property named `pf` and use `WS_URL` as the default (when support would be properly embedded in the namespace). In short I suspect you are using a jax-ws implementation that doesn't support Spring 4.2 and you need to upgrade that as well. – M. Deinum Dec 13 '16 at 14:39
  • pf is just used by our customPlaceholderConfigurer. I updated post. – Lucas Pouzac Dec 13 '16 at 15:08

0 Answers0