spencergibb / spring-cloud-gateway-mvc-sample

Spring Cloud Gateway MVC Sample
Apache License 2.0
23 stars 9 forks source link

spring-cloud-gateway-mvc giving 404 NOT_FOUND when deployed to Tomcat servlet 10.1.3 #2

Open raj111 opened 12 months ago

raj111 commented 12 months ago

Hi,

I built a gateway app for routing requests to another app using spring-cloud-gateway-mvc lib. It is working fine with embedded tomcat, but when i tried the same deploying the app to tomcat servlet container, the response is 404 NOT_FOUND.

Embedded tomcat trace log:

2023-10-11 15:28:44 [http-nio-8081-exec-2] TRACE o.s.w.s.function.RequestPredicates - Pattern "/xyz/" matches against value "/xyz/getlist" 2023-10-11 15:28:44 [http-nio-8081-exec-2] TRACE o.s.w.s.function.RouterFunctions - Predicate "/xyz/" matches against "HTTP GET /xyz/getlist" 2023-10-11 15:28:44 [http-nio-8081-exec-2] TRACE o.s.w.s.f.s.RouterFunctionMapping - Mapped to org.springframework.web.servlet.function.HandlerFilterFunction$$Lambda$1154/0x000000080119c088@54dc2a8d 2023-10-11 15:28:45 [http-nio-8081-exec-2] TRACE o.s.web.servlet.DispatcherServlet - No view rendering, null ModelAndView returned. 2023-10-11 15:28:45 [http-nio-8081-exec-2] DEBUG o.s.web.servlet.DispatcherServlet - Completed 200 OK, headers={masked}

Here is the trace log from Tomcat Servlet:

2023-10-11 15:31:23 [http-nio-8080-exec-214] TRACE o.s.w.s.function.RequestPredicates - Pattern "/xyz/" matches against value "/xyz/getlist" 2023-10-11 15:31:23 [http-nio-8080-exec-214] TRACE o.s.w.s.function.RouterFunctions - Predicate "/xyz/" matches against "HTTP GET /xyz/getlist" 2023-10-11 15:31:23 [http-nio-8080-exec-214] TRACE o.s.w.s.f.s.RouterFunctionMapping - Mapped to org.springframework.web.servlet.function.HandlerFilterFunction$$Lambda$17420/0x0000000802574638@53a185bc 2023-10-11 15:31:23 [http-nio-8080-exec-214] TRACE o.s.web.servlet.DispatcherServlet - No view rendering, null ModelAndView returned. 2023-10-11 15:31:23 [http-nio-8080-exec-214] DEBUG o.s.web.servlet.DispatcherServlet - Completed 404 NOT_FOUND, headers={masked}

Route Configuration:

   @Bean
public RouterFunction<ServerResponse> getRoute() throws MalformedURLException {
    return route("route1")
            .route(path("/xyz/**"), http(URI.create("http://test.com/xyz")))
            .build();
}

Any insights will be appreciated. TIA

spencergibb commented 12 months ago

I've no idea

httpmurilo commented 2 months ago

Good morning, this module is not compatible with deploy via .war

Spring Cloud Gateway requires the Netty runtime provided by Spring Boot and Spring Webflux. It does not work in a traditional Servlet Container or when built as a WAR.

spencergibb commented 2 months ago

@httpmurilo that is incorrect, spring cloud gateway MVC is compatible with tomcat