Skip to content

RedisHttpSessionConfiguration breaks application due to PropertyPlaceholderConfigurer #867

@mrusinak

Description

@mrusinak

Using Spring Session 1.3.1

RedisHttpSessionConfiguration defines a default PropertyPlaceholderConfigurer - this can cause an application to fail to initialize if the app defines it's own PropertyPlaceholderConfigurer that looks for properties in non-standard locations.

For example, consider a custom configurer that looks in two non-standard locations (one for defaults bundled with the app, another to allow for overrides):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <context:component-scan/>

    <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
        <property name="ignoreResourceNotFound" value="true" />
        <property name="locations">
            <list>
                <value>classpath:spring/defaults.properties</value>
                <value>file:${catalina.base}/conf/overrides.properties</value>
            </list>
        </property>
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
    </bean>

</beans>

And a dumb configuration object that uses @Value:

@Component
public class AppProperties {
    @Value( "${value1}" )
    private String value1;

    @Value( "${value2}" )
    private String value2;

    public String getValue1() {
        return value1;
    }

    public String getValue2() {
        return value2;
    }
}

(And of course, with a /spring/defaults.properties under src/main/resources, with value1 and value2 set)

Once <bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"/> is added as a bean, the app fails to initialize with being unable to resolve the values for AppProperties, as the PropertyPlaceholderConfigurer from RedisHttpSessionConfiguration gets tried and dies resolving them.

Metadata

Metadata

Assignees

Labels

for: stack-overflowA question that's better suited to stackoverflow.com

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions