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

Gradle RuntimeException '@FormParam' and '@RestForm' can only be used on methods annotated with '@Consumes(MediaType.MULTIPART_FORM_DATA)' #47167

Open
arey opened this issue Apr 4, 2025 · 5 comments
Labels
area/rest kind/bug Something isn't working

Comments

@arey
Copy link

arey commented Apr 4, 2025

Describe the bug

I've been working for a few months on a Spring Petclinic fork based on Quakus. It uses almost all the Spring extensions provided by Quarkus : Spring DI, Spring Web, Spring Data JPA, Spring Cache and Spring Boot

I've noticed a difference in behaviour between the Gradle and Maven builds of my quarkus-spring-petclinic application.

The Maven build succeeds. The Gradle build fails. I don't know why?
Both build configurations should be using the same Quarlus artifact versions.

Expected behavior

With the same Java base code, gradle and maven build should produces the same behaviour.

Actual behavior

Successful Maven build logs can be found here: https://github.com/spring-petclinic/quarkus-spring-petclinic/actions/runs/14236867795/job/39897740064
Below I explain how to reproduce the Gradle error. I have attached my local logs to this post:
gradle.log.zip

The stacktrace:

Caused by: java.lang.RuntimeException: '@FormParam' and '@RestForm' can only be used on methods annotated with '@Consumes(MediaType.MULTIPART_FORM_DATA)' '@Consumes(MediaType.APPLICATION_FORM_URLENCODED)'. Offending method is 'org.springframework.samples.petclinic.owner.OwnerRepositoryJaxRs_67b39fdc404ae23c4212d0aee4054338ea689aef#jakarta.ws.rs.core.Response add(org.springframework.samples.petclinic.owner.Owner entity, jakarta.ws.rs.core.UriInfo uriInfo)'
        at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:686)
        ... 13 more

The error comes from the EndpointIndexer class:

"'@FormParam' and '@RestForm' can only be used on methods annotated with '@Consumes(MediaType.MULTIPART_FORM_DATA)' '@Consumes(MediaType.APPLICATION_FORM_URLENCODED)'. Offending method is "

To temporary fix the Gradle build error, you could try to remove the 4 @FormParam annotations from the Owner class (but it breaks later the UI on the Owner update screen)

How to Reproduce?

Clone and build the quarkus-spring-petclinic project:

  1. git clone https://github.com/spring-petclinic/quarkus-spring-petclinic.git
  2. ./gradlew --console=plain quarkusDev

Output of uname -a or ver

Darwin MacBook.local 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041 arm64

Output of java -version

OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS)

Quarkus version or git rev

3.21.0

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 8.12

Additional information

I hope this problem is not due to an error in my use of Quarkus.

@arey arey added the kind/bug Something isn't working label Apr 4, 2025
@quarkus-bot quarkus-bot bot added the area/gradle Gradle label Apr 4, 2025
Copy link

quarkus-bot bot commented Apr 4, 2025

/cc @glefloch, @quarkusio/devtools

@geoand geoand added area/rest and removed area/gradle Gradle labels Apr 4, 2025
@geoand
Copy link
Contributor

geoand commented Apr 4, 2025

Thanks for reporting!

Can you please provide the instruction I can use to reproduce the problem?

@geoand geoand added the triage/needs-feedback We are waiting for feedback. label Apr 4, 2025
@arey
Copy link
Author

arey commented Apr 4, 2025

Sure @geoand I've gave them in the How to Reproduce? section. You need to clone the https://github.com/spring-petclinic/quarkus-spring-petclinic.git repository and then run the gradle build. It should fail.
You can compare the Maven build that succeeds.

@geoand geoand removed the triage/needs-feedback We are waiting for feedback. label Apr 7, 2025
@geoand
Copy link
Contributor

geoand commented Apr 7, 2025

This happens in the Gradle version and not the Maven version because of the presense of implementation 'io.quarkus:quarkus-spring-data-rest in the former and not the latter.

@gsmet
Copy link
Member

gsmet commented Apr 7, 2025

@arey btw, this is an interesting project. Would you be interested in sharing your story at some point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants