Open muzuro opened 6 years ago
I seem to have hit that same issue when trying to test a gateway application, and am trying to understand my options. Specifically I have a gateway application with some routes that I want to stub out for unit testing.
It looks like this makes the gateway incompatible with every mock server I've tried (okhttp mockserver, wiremock, mockserver-netty), as the mock response is not castable to NettyDataBufferFactory.
Does this sound right so far? If so has anyone came up with a workaround for testing? I'm thinking, instead of using a mock server, stubbing WebClient out might be a suitable option also?
Is this issue resolved with Greenwich.SR3 release. Is there a sample pom to use Tomcat with spring cloud gateway?
@spencergibb : Is this issue resolved with Greenwich.SR3 release. Is there a sample pom to use Tomcat with spring cloud gateway?
No. It won't be in Greenwich, it will be in a Hoxton Service Release (SR)
85193a0d98fb9f8b1caabc30071a8a9041d69536 may have fixed this functionality. The class cast exceptions mentioned here https://github.com/spring-cloud/spring-cloud-gateway/issues/145#issue-284704955 are now gone.
Remaining items:
WebSocketClient
per container (see here for appropiate class conditions)
// workaround for tomcat
@Bean
@Primary
TomcatWebSocketClient tomcatWebSocketClient() {
return new TomcatWebSocketClient();
}
Hmm those would be tests inside the gateway or some separate ones? Cause we could even embed running those tests inside the gateway build.
Just all the tests already in gateway
See #1544 for progress
@spencergibb Is it possible to use tomcat with gateway now?
Hi @spencergibb
I wanna use WebClientHttpRoutingFilter
and WebClientWriteResponseFilter
with Netty.
Is there any issue with Netty?
And is there any way to disable NettyRoutingFilter
?
@dlsrb6342 it's unrelated to this issue. There's no way to disable the netty beans at this moment.
Hi @spencergibb Any update when tomcat support will be added to Spring cloud gateway please?
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(); }`
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)
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(); }`
Hi @manisha-shetty , i still face same issue even after adding the above Beans
I added the above mentioned Beans in below class
@EnableMethodSecurity
@EnableWebFluxSecurity
@Configuration
public class SecurityConfig extends WebFluxAutoConfiguration {
}
Is this correct?
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)
Hi @klaus-cicd , is this resolved?
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:
Hower it is not enough, i get ClassCastException:
Is it possible to use tomcat with gateway instead netty? Thanks!