Skip to content

Regression in Spring 5.1 [SPR-17305] #21838

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
spring-projects-issues opened this issue Sep 26, 2018 · 1 comment
Closed

Regression in Spring 5.1 [SPR-17305] #21838

spring-projects-issues opened this issue Sep 26, 2018 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: invalid An issue that we don't feel is valid

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Sep 26, 2018

Alex opened SPR-17305 and commented

I'm trying to upgrade my project from Boot 2.0.x to Boot 2.1.x in order to leverage Spring 5.1 but the application won't start due a problem configuring the websocket support.

I've a class defined this way:

public class StompWebSocketConfig extends WebSocketMessageBrokerConfigurationSupport implements WebSocketMessageBrokerConfigurer

 

with this method:

@Bean
@Override
public WebSocketHandler subProtocolWebSocketHandler() 
{   return new CustomSubProtocolWebSocketHandler(clientInboundChannel(), clientOutboundChannel(), sessionService); }
 

And while trying to run the application I get this error:

 


APPLICATION FAILED TO START


Description:

The bean 'subProtocolWebSocketHandler', defined in class path resource [wf/bitcoin/chainmaster/StompWebSocketConfig.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:558)
at java.lang.Thread.run (Thread.java:748)
Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'subProtocolWebSocketHandler' defined in class path resource [wf/bitcoin/chainmaster/StompWebSocketConfig.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=stompWebSocketConfig; factoryMethodName=subProtocolWebSocketHandler; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [.../StompWebSocketConfig.class]] for bean 'subProtocolWebSocketHandler': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration; factoryMethodName=subProtocolWebSocketHandler; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.class]] bound.
at org.springframework.beans.factory.support.DefaultListableBeanFactory.registerBeanDefinition (DefaultListableBeanFactory.java:896)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod (ConfigurationClassBeanDefinitionReader.java:274)

 


Affects: 5.1 GA

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Brian Clozel commented

As of Spring Boot 2.1 (and this issue in particular), bean overriding is disabled by default.

You should consider not overriding that particular bean (or use a different name), or switch off the configuration property.

For other questions on that, please join the Spring Boot Gitter channel.

 

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

2 participants