Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to load api definition after spring boot 3.4.0-M2 #2687

Closed
rajadilipkolli opened this issue Aug 26, 2024 · 7 comments
Closed

failed to load api definition after spring boot 3.4.0-M2 #2687

rajadilipkolli opened this issue Aug 26, 2024 · 7 comments

Comments

@rajadilipkolli
Copy link

Describe the bug

I am using spring-boot-starter-webflux in conjunction with springdoc-openapi-starter-webflux-ui 2.6.0 version , it was working with spring boot 3.3.3 version.

After upgrading the same to 3.4.0-M2 , I am getting below error on UI loading, skeleton is rendered but apis are not due to below error.

Failed to fetch /v3/api-docs

Expected behavior

UI loaded with APIs

Screenshots
image

Additional context

Stacktrace :

app.log

@mikrobestie
Copy link

mikrobestie commented Aug 30, 2024

I can confirm this issue, it happens to me when I have a custom @RestControllerAdvice bean in the project. When I commented it out, everything works.

Problematic code is in org.springdoc.core.service.GenericResponseService#getGenericMapResponse:

List<ControllerAdviceInfo> controllerAdviceInfosNotInThisBean = controllerAdviceInfos.stream()
    .filter(controllerAdviceInfo ->
        new ControllerAdviceBean(controllerAdviceInfo.getControllerAdvice()).isApplicableToBeanType(beanType))
    .filter(controllerAdviceInfo -> !beanType.equals(controllerAdviceInfo.getControllerAdvice().getClass()))
    .toList();

seems like the ControllerAdviceBean constructor has changed in SB 3.4

@mmoayyed
Copy link

mmoayyed commented Sep 9, 2024

If it helps, here is a stacktrace even without a custom @RestControllerAdvice:

Caused by: java.lang.NoSuchMethodError: 'void org.springframework.web.method.ControllerAdviceBean.<init>(java.lang.Object)'
	at org.springdoc.core.service.GenericResponseService.lambda$getGenericMapResponse$8(GenericResponseService.java:706)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
	at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
	at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
	at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
	at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
	at org.springdoc.core.service.GenericResponseService.getGenericMapResponse(GenericResponseService.java:708)
	at org.springdoc.core.service.GenericResponseService.build(GenericResponseService.java:247)
	at org.springdoc.api.AbstractOpenApiResource.calculatePath(AbstractOpenApiResource.java:499)
	at org.springdoc.api.AbstractOpenApiResource.calculatePath(AbstractOpenApiResource.java:676)
	at org.springdoc.webmvc.api.OpenApiResource.lambda$calculatePath$11(OpenApiResource.java:220)
	at java.base/java.util.Optional.ifPresent(Optional.java:178)
	at org.springdoc.webmvc.api.OpenApiResource.calculatePath(OpenApiResource.java:201)
	at org.springdoc.webmvc.api.OpenApiResource.lambda$getPaths$2(OpenApiResource.java:171)
	at java.base/java.util.Optional.ifPresent(Optional.java:178)
	at org.springdoc.webmvc.api.OpenApiResource.getPaths(OpenApiResource.java:150)
	at org.springdoc.api.AbstractOpenApiResource.getOpenApi(AbstractOpenApiResource.java:353)
	at org.springdoc.webmvc.api.OpenApiResource.openapiJson(OpenApiResource.java:125)
	at org.springdoc.webmvc.api.OpenApiWebMvcResource.openapiJson(OpenApiWebMvcResource.java:114)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)

@efemoney
Copy link

ControllerAdviceBean is defined in spring-framework and this issue will affect EVERYONE upgrading SF to 6.2+ which is already on RC now.

Can we get some movement on this issue please.

@bnasslahsen
Copy link
Collaborator

bnasslahsen commented Sep 24, 2024

@efemoney

Thank you for raising this concern.
Please remember to should follow its contributing guidelines and code of conduct.

spring-boot 3.4 is not yet GA.

A good next step would be to propose a pull request (PR) to address the problem.
This will help move things forward faster by providing a concrete solution that can be reviewed and tested by the community.
If you haven't already, feel free to propose a PR so we can assess the fix and ensure it's implemented smoothly in time for the official release.

Otherwise, the community will address it when i or someone has the bandwidth to take a closer look.

@efemoney
Copy link

You're right, sorry. Spring 6.2 is in RC. I will push a PR once it's released. Thanks!

@gauravsg24
Copy link

Hello...Any further updates, with which springboot version it is going to be fixed ? I am at 3.4.1 and it's not working.

@rajadilipkolli
Copy link
Author

Hi @gauravsg24 , you should use 2.8.3 version with sb 3.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants
@mmoayyed @mikrobestie @efemoney @bnasslahsen @rajadilipkolli @gauravsg24 and others