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

Support running the gateway with other reactive containers besides netty #145

Open
muzuro opened this issue Dec 27, 2017 · 64 comments
Open
Projects

Comments

@muzuro
Copy link

muzuro commented Dec 27, 2017

I am trying to use tomcat instead netty. To achive this i have excluded netty from dependencies and included tomcat, so my build.gradle dependecies:

dependencies {
    compile (group: 'org.springframework.cloud', name: 'spring-cloud-starter-gateway', version: '2.0.0.M4') {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-netty'
    }
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '2.0.0.M7'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-webflux'
}

Hower it is not enough, i get ClassCastException:

java.lang.ClassCastException: org.springframework.core.io.buffer.DefaultDataBufferFactory cannot be cast to org.springframework.core.io.buffer.NettyDataBufferFactory
	at org.springframework.cloud.gateway.filter.NettyWriteResponseFilter.lambda$filter$0(NettyWriteResponseFilter.java:61) ~[spring-cloud-gateway-core-2.0.0.M4.jar:2.0.0.M4]
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44) ~[reactor-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
	at reactor.core.publisher.Mono.subscribe(Mono.java:2913) ~[reactor-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:167) ~[reactor-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]

Is it possible to use tomcat with gateway instead netty?
Thanks!

@muzuro muzuro changed the title TomcatConfiguration Tomcat instead netty Dec 27, 2017
@spencergibb
Copy link
Member

Not currently.

@spencergibb spencergibb changed the title Tomcat instead netty Support running the gateway with embedded servlet containers Jan 8, 2018
@spencergibb spencergibb changed the title Support running the gateway with embedded servlet containers Support running the gateway with other reactive containers besides netty Jan 8, 2018
@spencergibb
Copy link
Member

I already have code for this that just needs to be formalized. The difficulty will be running all the tests with other containers.

@grku2opia
Copy link

@spencergibb can u provide code ?

@spencergibb

This comment has been minimized.

@ghost
Copy link

ghost commented Feb 2, 2018

@spencergibb How is the progress now? Thank you

@spencergibb
Copy link
Member

None so far

@ghoddg

This comment has been minimized.

@spencergibb
Copy link
Member

@ghoddg this is likely not going to happen in 2.0.0. For now you have to use netty.

@ghoddg

This comment has been minimized.

@spencergibb
Copy link
Member

No

@ghoddg
Copy link

ghoddg commented Feb 14, 2018

@spencergibb Thanks for update.

@ghoddg
Copy link

ghoddg commented Feb 14, 2018

@spencergibb , from above communication, i got understanding that, API Gateway Service with Spring Cloud Gateway will not work with Tomcat as well as Weblogic for now and it will work only with netty.
is my understanding correct?

@dharezlak

This comment has been minimized.

@dharezlak
Copy link

I just noticed that this error occurs only in the testing mode. When run normally the gateway forwarding works fine.

@dharezlak
Copy link

Another thing I noticed is that when I use WebClient in tests instead of WebTestClient all is fine. Should using WebTestClient in spring-gateway based applications be prohibited?

@spencergibb
Copy link
Member

It's not. It is used to test the gateway

@dharezlak
Copy link

@spencergibb It is indeed. The source of my problem was using the @AutoConfigureWebTestClient annotation. Without it my tests are working fine. When I use it I get the ClassCastException mentioned earlier. Do you think this calls for a separate issue?

@drdamour
Copy link

drdamour commented Feb 22, 2018

are u open to pr's for tomcat support? for 2.0 or 2.1

@spencergibb
Copy link
Member

spencergibb commented Feb 22, 2018

@drdamour I already have code #145 (comment). The trouble is testing everything.

@drdamour
Copy link

yeah i assumed you meant unit test and thus PR.

what type of testing are you referring to then?

@spencergibb
Copy link
Member

Basically all the integration tests. Anything that spins up a container then makes real network calls thru the gateway.

@drdamour
Copy link

k...how are you hoping to structure the tests...duality for every netty test have a tomcat test. or just abstract away the backing implementation in all the tests?

or is there some prior art you are looking to follow?

@spencergibb
Copy link
Member

My guess is rerunning all the tests with some system properties. Copied tests is prohibitive. Most have a base class already.

@drdamour
Copy link

how will that work with your maven circle build? just 2+ surefire/failsafe executions?

@spencergibb
Copy link
Member

jenkins is our canonical build

@spencergibb
Copy link
Member

spencergibb commented Jan 14, 2020

85193a0 may have fixed this functionality. The class cast exceptions mentioned here #145 (comment) are now gone.

Remaining items:

  • Daily tests that run all tests against each of the other three containers. Possibly with maven profiles. @marcingrzejszczak thoughts?
  • WebSocketClient per container (see here for appropiate class conditions)
// workaround for tomcat
@Bean
@Primary
TomcatWebSocketClient tomcatWebSocketClient() {
	return new TomcatWebSocketClient();
}
  • ?

@marcingrzejszczak
Copy link
Contributor

Hmm those would be tests inside the gateway or some separate ones? Cause we could even embed running those tests inside the gateway build.

@spencergibb
Copy link
Member

Just all the tests already in gateway

@spencergibb spencergibb added this to To do in Hoxton.SR3 via automation Jan 24, 2020
@spencergibb spencergibb added this to the 2.2.2.RELEASE milestone Jan 24, 2020
spencergibb added a commit that referenced this issue Jan 24, 2020
Adds webserver module to host auto-configuration for abover web servers.

Adds profiles to core to run all tests with each webserver.

fixes gh-145
@spencergibb
Copy link
Member

See #1544 for progress

@jingbing
Copy link

@spencergibb Is it possible to use tomcat with gateway now?

@spencergibb spencergibb removed this from To do in Hoxton.SR5 May 29, 2020
@spencergibb spencergibb added this to To do in Hoxton.SR7 via automation May 29, 2020
@spencergibb spencergibb removed this from To do in Hoxton.SR7 Aug 4, 2020
@spencergibb spencergibb added this to To do in Backlog via automation Aug 4, 2020
@dlsrb6342
Copy link
Contributor

Hi @spencergibb
I wanna use WebClientHttpRoutingFilter and WebClientWriteResponseFilter with Netty.
Is there any issue with Netty?
And is there any way to disable NettyRoutingFilter?

@spencergibb
Copy link
Member

@dlsrb6342 it's unrelated to this issue. There's no way to disable the netty beans at this moment.

@gaurav1264
Copy link

Hi @spencergibb Any update when tomcat support will be added to Spring cloud gateway please?

@manisha-shetty
Copy link

Adding this to the webflux security config resolved the issue for me

`@Bean
@primary
public RequestUpgradeStrategy requestUpgradeStrategy() {
return new TomcatRequestUpgradeStrategy();
}

@bean
@primary
WebSocketClient tomcatWebSocketClient() {
return new TomcatWebSocketClient();
}`

@klaus-cicd
Copy link

New anomalies appear.

java.lang.ClassCastException: org.springframework.http.server.reactive.TomcatHttpHandlerAdapter$TomcatServerHttpRequest cannot be cast to javax.servlet.http.HttpServletRequest
at org.springframework.web.reactive.socket.server.upgrade.TomcatRequestUpgradeStrategy.getNativeRequest(TomcatRequestUpgradeStrategy.java:159)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Backlog
To do
Development

Successfully merging a pull request may close this issue.