Skip to content
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

Can not start spring application with webflux and websocket for ObjectPostProcessor is needed. #5932

Closed
Ayden-Franklin opened this issue Oct 10, 2018 · 6 comments
Assignees
Labels
status: invalid An issue that we don't feel is valid

Comments

@Ayden-Franklin
Copy link

Ayden-Franklin commented Oct 10, 2018

Summary

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' that could not be found.

Action:

Consider defining a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' in your configuration.

Actual Behavior

Fail to start. BUT it works well without dependency of 'org.springframework.boot:spring-boot-starter-websocket'

Configuration

@Configuration
@EnableWebFluxSecurity
public class WebSecurityConfig {
    @Bean
    public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
       ...
    }
   ...
}
@Configuration
public class WebSocketConfiguration {
    @Bean
    public HandlerMapping handlerMapping() {
        Map<String, WebSocketHandler> map = new HashMap<>();
        map.put("/websocket", new WebSocketMessageHandler());
        SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
        mapping.setUrlMap(map);
        mapping.setOrder(-1); // before annotated controllers
        return mapping;
    }

    @Bean
    public WebSocketHandlerAdapter handlerAdapter() {
        return new WebSocketHandlerAdapter();
    }
}

Version

spring boot 2.0.5.RELEASE
io.spring.platform:platform-bom:Cairo-SR4
org.springframework.cloud:spring-cloud-dependencies:Finchley.SR1

Sample

@rwinch
Copy link
Member

rwinch commented Oct 10, 2018

Thanks for the report. It almost sounds as though you are using the imperative (non-reactive) web socket support. Can you provide a complete stacktrace? Perhaps a small sample project?

@rwinch rwinch added the status: waiting-for-feedback We need additional information before we can continue label Oct 10, 2018
@Ayden-Franklin
Copy link
Author

Thanks for your response. I tried again and found that it works well while using dependency of 'org.springframework:spring-websocket' instead of 'org.springframework.boot:spring-boot-starter-websocket'. In deed, spring-boot-starter-websocket depends on 'org.springframework:spring-webmvc' to case this issue. We can exclude 'org.springframework:spring-webmvc' to avoid it.

I suggest that spring-boot-starter-websocket does not depends on 'org.springframework:spring-webmvc' or there is another spring-boot-starter-webflux-websocket which depends on 'org.springframework:spring-webflux' instead of 'org.springframework:spring-webmvc'.

@Ayden-Franklin
Copy link
Author

Perhaps because in my gradle dependencies 'spring-boot-starter-websocket' appears before 'org.springframework:spring-webflux'. It works strangely if there are both spring-webmvc and spring-webflux in the classpath.

@rwinch
Copy link
Member

rwinch commented Oct 11, 2018

Thanks for the additional details! Can you please create a sample and post this to spring-boot? They are in charge of the autoconfiguraiton and the starter poms. When you create that ticket, can you please provide a link here?

@Ayden-Franklin
Copy link
Author

14810
Sorry, I do not know how to link it. Is it ok?

@rwinch
Copy link
Member

rwinch commented Oct 16, 2018

Thanks that works.

I'm closing this issue as there is nothing we can do from the Spring Security side of things

@rwinch rwinch closed this as completed Oct 16, 2018
@rwinch rwinch removed the status: waiting-for-feedback We need additional information before we can continue label Oct 16, 2018
@rwinch rwinch self-assigned this Oct 16, 2018
@rwinch rwinch added the status: invalid An issue that we don't feel is valid label Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

2 participants