Skip to content

@RestControllerAdvice breaks /v3/api-docs in Spring Boot 3.5.3 (springdoc 2.5.0) #3045

@wooxexn

Description

@wooxexn

Describe the bug

  • When using Spring Boot 3.5.3 with springdoc-openapi-starter-webmvc-ui:2.5.0, defining a global exception handler using @RestControllerAdvice causes Swagger to break.
  • Accessing /v3/api-docs results in a 500 Internal Server Error.
  • Removing the global exception handler resolves the issue.
  • Even trying to bypass Swagger paths in the handler (e.g., if (uri.contains("swagger"))) does not help.
  • It seems the error happens before the handler is invoked, possibly due to an internal incompatibility.

To Reproduce

Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    → Spring Boot 3.5.3

  • What modules and versions of springdoc-openapi are you using?
    springdoc-openapi-starter-webmvc-ui:2.5.0

  • What is the actual and the expected result using OpenAPI Description (yml or json)?
    Expected: /v3/api-docs returns OpenAPI JSON and Swagger UI loads
    Actual: 500 Internal Server Error occurs and Swagger UI fails to load

  • Provide with a sample code (HelloController) or Test that reproduces the problem
    → Simple HelloController + GlobalExceptionHandler with @RestControllerAdvice on Exception.class


Expected behavior

  • Swagger should work normally even when global exception handling is enabled.
  • /v3/api-docs should return OpenAPI JSON schema and Swagger UI should render.

Screenshots

Not applicable – this is a backend error.
Logs show:
java.lang.NoSuchMethodError: 'void org.springframework.web.method.ControllerAdviceBean.<init>(java.lang.Object)'


Additional context

  • This issue seems related to Spring Framework 6.2, which is used under Spring Boot 3.5.3.
  • The internal use of ControllerAdviceBean in springdoc may not be compatible anymore.
  • This bug did not occur in Spring Boot 3.2.1 + springdoc 2.3.0.
  • Ignoring the Swagger path in the exception handler doesn’t help, suggesting the issue occurs at a deeper level in the framework.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions