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

Devtools restart does not work with reactor-netty #9146

Closed
snicoll opened this issue May 10, 2017 · 4 comments
Closed

Devtools restart does not work with reactor-netty #9146

snicoll opened this issue May 10, 2017 · 4 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented May 10, 2017

A WebFlux app using netty can lead to "ReactiveWebServerApplicationContext has been closed already"

2017-05-10 09:07:49.899 ERROR 14583 --- [ctor-http-nio-5] o.s.w.s.adapter.HttpWebHandlerAdapter    : Failed to handle request

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot resolve reference to bean 'reactiveMongoTemplate' while setting bean property 'reactiveMongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.data.mongodb-org.springframework.boot.autoconfigure.mongo.MongoProperties': Initialization of bean failed; nested exception is java.lang.IllegalStateException: org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext@426027f3 has been closed already
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) ~[spring-beans-5.0.0.RC1.jar:5.0.0.RC1]
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) ~[spring-beans-5.0.0.RC1.jar:5.0.0.RC1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1604) ~[spring-beans-5.0.0.RC1.jar:5.0.0.RC1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1349) ~[spring-beans-5.0.0.RC1.jar:5.0.0.RC1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:574) ~[spring-beans-5.0.0.RC1.jar:5.0.0.RC1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:491) ~[spring-beans-5.0.0.RC1.jar:5.0.0.RC1]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[spring-beans-5.0.0.RC1.jar:5.0.0.RC1]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-5.0.0.RC1.jar:5.0.0.RC1]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) ~[spring-beans-5.0.0.RC1.jar:5.0.0.RC1]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) ~[spring-beans-5.0.0.RC1.jar:5.0.0.RC1]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:250) ~[spring-beans-5.0.0.RC1.jar:5.0.0.RC1]

@bclozel
Copy link
Member

bclozel commented May 10, 2017

This behavior shows that after stopping and restarting a new server instance with the new Spring context, reactor-netty's HttpServer has still a reference to the previous handler, which holds itself a reference to the old Spring WebFlux infrastructure (beans, context and all).

I've opened reactor/reactor-netty#90 as our current use of the HttpServer API is wrong, or there might be a bug in reactor-netty.

@wilkinsona
Copy link
Member

I can't reproduce this with the WebFlux and Reactive MongoDB starters. Have I missed something?

@bclozel
Copy link
Member

bclozel commented Jun 19, 2017

Are you using Reactor Netty, or another server implementation instead (Tomcat, Undertow, Jetty?).

The other possible reason is that the changes you're making to your project aren't "incompatible" with the previous version which still runs. Declaring a WebFlux controller handler and changing its behavior (as I've done in the reactor netty issue I've created) should trigger the issue.

Note: technically, that BeanCreationException is not the issue to reproduce, but rather the application still using the context that has been closed already.

bclozel added a commit that referenced this issue Jul 18, 2017
This commit is a temporary workaround for gh-9146; it cleans the HTTP
resources associated with the Netty server.
@bclozel
Copy link
Member

bclozel commented Jul 18, 2017

Note: I've added a temporary workaround for this in 330aa70

@bclozel bclozel modified the milestones: 2.0.0.M4, 2.0.0.M3 Jul 25, 2017
@bclozel bclozel added the status: blocked An issue that's blocked on an external project change label Jul 25, 2017
@bclozel bclozel modified the milestones: 2.0.0.M5, 2.0.0.M4 Aug 23, 2017
@philwebb philwebb modified the milestones: 2.0.0.M5, 2.0.0.RC2, 2.0.0.RC1 Sep 20, 2017
@bclozel bclozel modified the milestones: 2.0.0.M7, 2.0.0.RC1 Nov 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants