Spring Boot version: 2.4.2 Sample project: https://github.com/amarkevich/spring-boot-jwt-test

ControllerPreAuthorizeImpl implements 2 annotated interfaces.

  1. spring-boot-application>mvn test -Dtest=ApplicationTest#getFailure

o.s.web.client.RestTemplate : Reading to [java.lang.String] as "application/json" o.s.web.servlet.DispatcherServlet : GET "/failure", parameters={} o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler [class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], ServletContext resource [/]] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND

When implemented interface sequence changed to implements ControllerFailure, ControllerPreAuthorize the test is passed

  1. spring-boot-application>mvn test -Dtest=ApplicationTest#getJsonPreAuthorize

o.s.web.client.RestTemplate : Reading to [java.lang.String] as "application/json" o.s.web.servlet.DispatcherServlet : GET "/v2", parameters={} s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to com.wedextim.spring.boot.application.controller.impl.ControllerPreAuthorizeImpl#getFailure() .w.s.m.a.ResponseStatusExceptionResolver : Resolved [com.wedextim.spring.boot.application.controller.impl.ControllerPreAuthorizeImpl$ProcessingException: failure message] o.s.web.servlet.DispatcherServlet : Completed 422 UNPROCESSABLE_ENTITY

wrong mapping: expected getJson, actual getFailure()

Comment From: wilkinsona

Thanks for the sample. Unfortunately, I'm finding it rather confusing and the intent isn't very clear to me. You have both JAX-RS and Spring MVC annotations and I'm not sure which you intend to win. You also have JAX-RS and Spring MVC mapping annotations on ControllerFailure and ControllerPreAuthorize. ControllerPreAuthorizeImpl implements both and therefore has overlapping configuration coming from the two interfaces. I don't understand what the intent is here or how you expect the overlapping configuration to be resolved.

If you'd like us to spend some more time investigating, can you please do a couple of things:

  1. Reduce the sample to the bare minimum that is needed to reproduce the problem
  2. Explain what you intend to happen and what you see happening instead

Comment From: amarkevich

  1. https://github.com/amarkevich/spring-boot-jwt-test/tree/%2325008
  2. I want to implement multiple contracts using single controller implementation. Actually endpoints handled incorrectly.

Comment From: wilkinsona

Thanks for simplifying things. You still have two @RequestMapping annotations at the class level on ControllerImpl. One mapping is from Controller and the other is from ControllerFailure. Spring MVC does not support this arrangement as it's not clear which should win. Your tests pass if you move the mappings to the method level:

diff --git a/spring-boot-application/src/main/java/com/wedextim/spring/boot/application/controller/Controller.java b/spring-boot-application/src/main/java/com/wedextim/spring/boot/application/controller/Controller.java
index 001bf5c..fd2a90f 100644
--- a/spring-boot-application/src/main/java/com/wedextim/spring/boot/application/controller/Controller.java
+++ b/spring-boot-application/src/main/java/com/wedextim/spring/boot/application/controller/Controller.java
@@ -4,13 +4,12 @@ import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;

-@RequestMapping("/v1")
 public interface Controller {

-    @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE)
+    @GetMapping(path="/v1", produces = MediaType.TEXT_PLAIN_VALUE)
     String getPlain();

-    @GetMapping
+    @GetMapping(path="/v1")
     String[] getJson();

 }
diff --git a/spring-boot-application/src/main/java/com/wedextim/spring/boot/application/controller/ControllerFailure.java b/spring-boot-application/src/main/java/com/wedextim/spring/boot/application/controller/ControllerFailure.java
index 4e91c8a..1d8751b 100644
--- a/spring-boot-application/src/main/java/com/wedextim/spring/boot/application/controller/ControllerFailure.java
+++ b/spring-boot-application/src/main/java/com/wedextim/spring/boot/application/controller/ControllerFailure.java
@@ -4,12 +4,11 @@ import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;

-@RequestMapping("/failure")
 public interface ControllerFailure {

     String FAILURE_MESSSAGE = "failure message";

-    @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
+    @GetMapping(path="/failure", produces = MediaType.APPLICATION_JSON_VALUE)
     String getFailure();

 }

If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.