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

Error java.lang.NoSuchMethodError for HttpMethod.resolve(). #1760

Open
userMuratt opened this issue Jan 2, 2024 · 2 comments · May be fixed by #1767
Open

Error java.lang.NoSuchMethodError for HttpMethod.resolve(). #1760

userMuratt opened this issue Jan 2, 2024 · 2 comments · May be fixed by #1767

Comments

@userMuratt
Copy link

When upgrading my project to Spring Boot 3.2.1, I get the following error:

'org.springframework.http.HttpMethod org.springframework.http.HttpMethod.resolve(java.lang.String)' java.lang.NoSuchMethodError: 'org.springframework.http.HttpMethod org.springframework.http.HttpMethod.resolve(java.lang.String)' at io.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.toValidHttpMethod(MockMvcRequestSenderImpl.java:855) at io.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.request(MockMvcRequestSenderImpl.java:805) at io.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.request(MockMvcRequestSenderImpl.java:801) at io.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.request(MockMvcRequestSenderImpl.java:105) at io.restassured.module.mockmvc.internal.MockMvcRequestSpecificationImpl.request(MockMvcRequestSpecificationImpl.java:759) at io.restassured.module.mockmvc.internal.MockMvcRequestSpecificationImpl.request(MockMvcRequestSpecificationImpl.java:65)

HttpMethod.resolve() is used with Spring-web 6.0.15 at the latest: https://docs.spring.io/spring-framework/docs/6.0.15/javadoc-api/org/springframework/http/HttpMethod.html.

What is the recommended way?

@a-s-rose
Copy link

a-s-rose commented Jan 22, 2024

Same for me here, too. Seems the actual version of rest-assured is not fully compatible with spring 6.x.

I use the concrete methods now, e.g. instead of

given.when.request("DELETE", "/mypath")...

I use

given.when.delete("/mypath")...

d0vi added a commit to d0vi/rest-assured that referenced this issue Jan 31, 2024
On Spring Framework 5, `HttpMethod` is an enum type that exposes a `resolve(java.lang.String)` method that matches the String value passed with the enum value while handling null values gracefully. However, in the context of `toValidHttpMethod(java.lang.String)`, there is a previous assertion that ensures `null` will not be passed moving forward. Hence, using enum's native `valueOf` directly seems like a good idea.

Furthermore, Spring Framework 6.0 marked `HttpMethod#resolve(java.lang.String)` as deprecated for removal, and starting from Spring Framework 6.1 this API element no longer exists. This change is currently causing issues (rest-assured#1760) with latest Spring Framework and Spring Boot versions.

This commit replaces the use of this method with the equivalent `HttpMethod#valueOf(java.lang.String)`.
@d0vi d0vi linked a pull request Jan 31, 2024 that will close this issue
felhag added a commit to felhag/rest-assured that referenced this issue Mar 28, 2024
@felhag
Copy link

felhag commented Mar 28, 2024

Any updates on this? Created a similar pull request to fix WebTestClientRequestSenderImpl:

#1778

d0vi added a commit to d0vi/rest-assured that referenced this issue Apr 1, 2024
On Spring Framework 5 `HttpMethod` is an enum type that exposes a `resolve(java.lang.String)` method that matches the String value passed with the enum value while handling null values gracefully. However, in the context of `toValidHttpMethod(java.lang.String)`, there is a previous assertion that ensures `null` will not be passed moving forward. Hence, using enum's native `valueOf` directly seems like a good idea.

Furthermore, Spring Framework 6.0 marked `HttpMethod#resolve(java.lang.String)` as deprecated for removal, and starting from Spring Framework 6.1 this API element no longer exists. This change is currently causing issues (rest-assured#1760) with latest Spring Framework and Spring Boot versions.

This commit replaces the use of this method with the equivalent `HttpMethod#valueOf(java.lang.String)`.

Closes rest-assured#1760.
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

Successfully merging a pull request may close this issue.

3 participants