Skip to content

Unable to obtain SessionCookieConfig #1040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lglapinski opened this issue Apr 9, 2018 · 6 comments
Closed

Unable to obtain SessionCookieConfig #1040

lglapinski opened this issue Apr 9, 2018 · 6 comments
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@lglapinski
Copy link

lglapinski commented Apr 9, 2018

Hi!

I have following configuration:

spring - 5.0.5
spring session - 5.0.4
spring session data redis - 2.0.2

During each deployment I see this:

WARN  RedisHttpSessionConfiguration$$EnhancerBySpringCGLIB$$35c2575f:174 - Unable to obtain SessionCookieConfig: Section 4.4 of the Servlet 3.0 specification does not permit this method to be called from a ServletContextListener that was not defined in web.xml, a web-fragment.xml file nor annotated with @WebListener

Configuration:

public class SecurityInitializer extends AbstractSecurityWebApplicationInitializer {
}
public class SessionInitializer extends AbstractHttpSessionApplicationInitializer {
}
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class<?>[]{AppConfig.class, AsyncConfig.class, PersistenceConfig.class, RedisConfig.class,
                SchedulingConfig.class, SecurityConfig.class, WebMvcConfig.class};
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return null;
    }

    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    @Override
    protected Filter[] getServletFilters() {
        return new Filter[]{
                new CharacterEncodingFilter("UTF-8", true)
        };
    }

@Configuration
@EnableRedisHttpSession
public class RedisConfig {
    @Value("${REDIS_ENDPOINT:localhost}")
    private String redisEndpoint;

    @Value("${REDIS_PORT:6379}")
    private Integer redisPort;

    @Bean
    public ConfigureRedisAction configureRedisAction() {
        return ConfigureRedisAction.NO_OP;
    }

    @Bean
    public LettuceConnectionFactory connectionFactory() {
        return new LettuceConnectionFactory(new RedisStandaloneConfiguration(redisEndpoint, redisPort));
    }

    @Bean
    RedisSerializer<Object> springSessionDefaultRedisSerializer() {
        return new CustomRedisSerializer();
    }
}
@vpavic vpavic self-assigned this Apr 18, 2018
@vpavic
Copy link
Contributor

vpavic commented Apr 18, 2018

Thanks for the report @lglapinski. Could you provide a sample app that we can use to reproduce this issue? Also which servlet container are you running your app in?

@vpavic vpavic added the status: waiting-for-feedback We need additional information before we can continue label Apr 18, 2018
@lglapinski
Copy link
Author

lglapinski commented Apr 23, 2018

It's Apache Tomcat/8.0.47
I'm not able to repro that with plain new app. I will try to repro this issue and circle back.

@vpavic vpavic added this to the General Backlog milestone Nov 9, 2018
@vpavic
Copy link
Contributor

vpavic commented Jan 12, 2019

This issue can be reproduced using Spring Session's Java config based sample apps.

@vpavic vpavic added type: bug A general bug and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 12, 2019
@guidev
Copy link

guidev commented Jan 19, 2019

Same here when trying to use @EnableRedisHttpSession following https://docs.spring.io/spring-session/docs/current/reference/html5/guides/java-redis.html.

@EnableRedisHttpSession
@Log4j2
public class RedisConfig {

    @Bean
    public LettuceConnectionFactory connectionFactory() {
        RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
        configuration.setHostName("xxxxxxxx.eu-central-1-1.ec2.cloud.redislabs.com");
        configuration.setPort(15304);
        configuration.setPassword("xxxxxxxx");
        return new LettuceConnectionFactory(configuration);
    }
}


public class SessionInitializer extends AbstractHttpSessionApplicationInitializer {

    public SessionInitializer() {
        super(RedisConfig.class);
    }
}

Tomcat: 9.0.14 and 8.5.37
spring-webmvc: 5.1.4.RELEASE
spring-session-data-redis: 2.1.3.RELEASE
lettuce-core: 5.1.3.RELEASE

@vpavic
Copy link
Contributor

vpavic commented Jan 29, 2019

As this works in app with XML based config, it appears the problem might be in Spring Framework - I've opened spring-projects/spring-framework#22319.

@vpavic
Copy link
Contributor

vpavic commented Jan 29, 2019

Since this really appears to be a limitation in Spring Framework, I'm going to close this one as duplicate - please track spring-projects/spring-framework#22319 for further developments.

@vpavic vpavic closed this as completed Jan 29, 2019
@vpavic vpavic added status: duplicate A duplicate of another issue and removed type: bug A general bug labels Jan 29, 2019
@vpavic vpavic removed this from the General Backlog milestone Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants