-
Notifications
You must be signed in to change notification settings - Fork 126
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
Spring Boot 3 and Webflux - NoSuchMethodError ResponseEntity.status #792
Comments
I am also getting this exception with Spring Boot |
@MichaelJHaywood would you accept a PR for updating dependencies or is there already a progress about latest Spring and Spring boot version? |
Is there any update on this? I am currently facing the same issue and it is preventing me from migrating a project to Spring Boot v3. |
I had opened a PR and it was merged. You can try this version. https://github.com/zalando/problem-spring-web/tree/0.28.0-RC.1 |
Interesting... I tested exactly this release candidate this morning and I still run into the same issue. Every exception I throw fails with this uncaught exception inbetween:
When I step through the debugger it seems to fail somewhere in The AdviceTrait in my code that creates this is extremely simple:
|
I also encountered same issue with non-reactive and same RC |
please provide a sample app to test. |
As you can see here in the newest version of Spring Web 6.0.6, they changed the |
yup, same error for me |
Actually, the error might suggest that Interestingly, Maven Central reports that https://central.sonatype.com/artifact/org.zalando/problem-spring-webflux/0.28.0-RC.1/dependencies If @whiskeysierra or @MALPI be so kind to release a new version, that I think would solve the problem. Meanwhile, here is the workaround that worked for me. In your ControllerAdvice just override methods that invoking @ControllerAdvice
class ExceptionHandling implements ProblemHandling {
private static ResponseEntity<Problem> fallback(final Problem problem, final HttpHeaders headers) {
return ResponseEntity
.status(HttpStatus.valueOf(Optional.ofNullable(problem.getStatus())
.orElse(Status.INTERNAL_SERVER_ERROR)
.getStatusCode()))
.headers(headers)
.contentType(PROBLEM)
.body(problem);
}
@Override
public Mono<ResponseEntity<Problem>> fallback(
@SuppressWarnings("UnusedParameters") final Throwable throwable,
final Problem problem,
@SuppressWarnings("UnusedParameters") final ServerWebExchange request,
final HttpHeaders headers) {
return Mono.just(fallback(problem, headers));
}
@Override
public Mono<ResponseEntity<Problem>> create(final Throwable throwable, final Problem problem,
final ServerWebExchange request, final HttpHeaders headers) {
final HttpStatus status = HttpStatus.valueOf(Optional.ofNullable(problem.getStatus())
.orElse(Status.INTERNAL_SERVER_ERROR)
.getStatusCode());
return log(throwable, problem, request, status)
.doOnSuccess(it -> {
if (status == HttpStatus.INTERNAL_SERVER_ERROR) {
request.getAttributes().put(ERROR_EXCEPTION, throwable);
}
})
.then(Mono.justOrEmpty(negotiate(request)))
.map(contentType -> ResponseEntity
.status(status)
.headers(headers)
.contentType(contentType)
.body(problem)
)
.switchIfEmpty(fallback(throwable, problem, request, headers))
.flatMap(entity -> process(entity, request));
}
} |
Thanks @nstdio you pointed me in the right direction. For me I only had to copy
|
I still got the NoSuchMethodException. I used 0.28.0-RC.1. `2023-04-18T23:33:12.742+06:30 DEBUG 12936 --- [ parallel-2] o.s.s.w.s.a.AuthorizationWebFilter : Authorization failed: Access Denied java.lang.NoSuchMethodError: 'org.springframework.http.HttpStatus org.springframework.http.ResponseEntity.getStatusCode()' |
@kyawswar87 : Try |
I'm using
spring boot 3
,spring-webflux
andproblem-spring-webflux
.I would like to catch
unauthorized
andaccess denied
exceptions and return the relevant problem object. To do this I've added aSecurityExceptionHandler
and included the configuration in aSecurityConfiguration
class.SecurityExceptionHandler
SecurityConfiguration
When I access the service without a token a
NoSuchMethod
exception is thrown.gradle.build
I'm assuming this is dependency related but I have access to these classes/methods which leads me to believe it could be compatibility with
spring boot 3
.What is causing this?
The text was updated successfully, but these errors were encountered: