springspring-webfluxreactive

Spring Functional Endpoints returning 404


I'm creating an application using both regular endpoints and functional endpoints. If I hit any created with the regular endpoints, I get the desired results. But introducing the functional endpoints, all return 404. I'm following a few different tutorials and all seem to be using the same pattern with a handler and a router as I implented.

Here's the Handler:

@Service
public class LorcCardHandler {
    private final LorcCardReactiveRepository lorcCardReactiveRepository;

    @Autowired
    public LorcCardHandler(LorcCardReactiveRepository lorcCardReactiveRepository) {
        this.lorcCardReactiveRepository = lorcCardReactiveRepository;
    }

    public Mono<ServerResponse> getCardProjectionList(ServerRequest request) {
        return ServerResponse.ok().body(lorcCardReactiveRepository.getAllCardsProjection(), CardProjection.class);
    }

}

And here's the router

@Configuration
public class LorcRouter {
    private final LorcCardHandler handler;

    public LorcRouter(LorcCardHandler handler) {
        this.handler = handler;
    }

    @Bean
    public RouterFunction<ServerResponse> getCardListByRoute() {
       return route().path("/lorc", builder -> builder.GET(handler::getCardProjectionList)).build();
    }
}

EDIT: As requested, adding the logs Initialization of relevant beans

o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from beaame 'reactiveMongoTemplate' via factory method to beaamed 'mappingMongoConverter' o.s.d.r.c.s.RepositoryFactorySuppo: Initializing repository instance for com.luizgomendes.lorc.rest.repository.LorcCardReactiveRepository… o.s.d.r.c.s.RepositoryFactorySuppo: Finished creation of repository instance for com.luizgomendes.lorc.rest.repository.LorcCardReactiveRepository. o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from beaame 'lorcReactiveService' via constructor to beaamed 'lorcCardReactiveRepository' o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from beaame 'lorcReactiveController' via constructor to beaamed 'lorcReactiveService' o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'lorcRouter' o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'lorcCardHandler' o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from beaame 'lorcCardHandler' via constructor to beaamed 'lorcCardReactiveRepository' o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from beaame 'lorcRouter' via constructor to beaamed 'lorcCardHandler' o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'globalExceptionHandler' o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'getCardListByRoute'

Service call

[Lorcana Rest Services] [nio-8080-exec-1] o.s.web.servlet.DispatcherServle : GET "/lorc", parameters={} [Lorcana Rest Services] [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]] [Lorcana Rest Services] [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandl: Resourcot found [Lorcana Rest Services] [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.servlet.resource.NoResourceFoundException: No static resource lorc.] [Lorcana Rest Services] [nio-8080-exec-1] o.s.web.servlet.DispatcherServle : Completed 404 NOT_FOUND [Lorcana Rest Services] [nio-8080-exec-1] o.s.web.servlet.DispatcherServle : "ERROR" dispatch for GET "/error", parameters={} [Lorcana Rest Services] [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse) [Lorcana Rest Services] [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8] [Lorcana Rest Services] [nio-8080-exec-1] o.s.web.servlet.DispatcherServle : Exiting from "ERROR" dispatch, status 404 [Lorcana Rest Services] [localhost:27017] org.mongodb.driver.cluste: Updating cluster description t{type=STANDALONE, servers=[{address=localhost:27017, type=STANDALONE, roundTripTime=81.2 ms, state=CONNECTED}] [Lorcana Rest Services] [localhost:27017] org.mongodb.driver.cluste: Checking status of localhost:27017 [Lorcana Rest Services] [localhost:27017] org.mongodb.driver.cluste: Updating cluster description t{type=STANDALONE, servers=[{address=localhost:27017, type=STANDALONE, roundTripTime=12.2 ms, state=CONNECTED}] [Lorcana Rest Services] [localhost:27017] org.mongodb.driver.cluste: Checking status of localhost:27017 [Lorcana Rest Services] [nio-8080-exec-3] o.apache.coyote.http11.Http11Processo: Error parsing HTTP request header java.io.EOFException: null at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1293) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1181) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:789) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:348) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:262) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1741) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63) ~[tomcat-embed-core-10.1.24.jar:10.1.24] at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]


Solution

  • Issue was an additional dependency on the pom.xml

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webflux</artifactId>
        <version>6.1.8</version>
    </dependency>
    

    I tried the same setup on a different project, and after I was successful I verified each dependency and see which ones were extra. After removing the above dependency, the functional endpoint worked as expected.