Skip to content

Beanparam without fields is not supported #47545

@Postremus

Description

@Postremus

Describe the bug

If I use a class as a @BeanParam, which has no fields annotated as jax-rs parameters (e.g. QueryParam), I get an exception on start. see below.

@Path("/hello")
public class GreetingResource {

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello(@BeanParam Params params) {
        return "Hello from Quarkus REST";
    }

    public static class Params {
        //@RestQuery
        //String matchCode;
    }
}

Expected behavior

The exception itself states
No annotations found on fields at 'org.acme.GreetingResource$Params'. Annotations like @QueryParam should be used in fields, not in methods.

However, the jakarta rest spec states (Appendix A):
https://jakarta.ee/specifications/restful-ws/4.0/jakarta-restful-ws-spec-4.0.pdf
Image

So this is behaviour which (unintentionally?) differs from the spec

No matter what decision is taken here, the log message itself is confusing. The second sentence does not seem to have any relevance to the first sentence?

Actual behavior

[ERROR] Errors: 
[ERROR]   GreetingResourceTest.testHelloEndpoint ┬╗ Runtime java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor#setupEndpoints threw an exception: java.lang.RuntimeException: java.lang.RuntimeException: Failed to process method 'org.acme.GreetingResource#java.lang.String hello(org.acme.GreetingResource$Params params)'                                                                                                                                                                                                                                                    
        at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:348)                                                                                                                                                                   
        at io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor.setupEndpoints(ResteasyReactiveProcessor.java:717)                                                                                                                                              
        at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)                                                                                                                                                                                       
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)                                                                                                                                                                                                
        at io.quarkus.builder.BuildContext.run(BuildContext.java:255)                                                                                                                                                                                                               
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)                                                                                                                                                                                                       
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)                                                                                                                                                                                  
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)                                                                                                                                                                                        
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)                                                                                                                                                                                   
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)                                                                                                                                                                                  
        at java.base/java.lang.Thread.run(Thread.java:1583)                                                                                                                                                                                                                         
        at org.jboss.threads.JBossThread.run(JBossThread.java:499)                                                                                                                                                                                                                  
Caused by: java.lang.RuntimeException: Failed to process method 'org.acme.GreetingResource#java.lang.String hello(org.acme.GreetingResource$Params params)'                                                                                                                         
        at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:812)                                                                                                                                                              
        at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:445)                                                                                                                                                                   
        at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:309)                                                                                                                                                                   
        ... 11 more                                                                                                                                                                                                                                                                 
Caused by: jakarta.enterprise.inject.spi.DeploymentException: No annotations found on fields at 'org.acme.GreetingResource$Params'. Annotations like `@QueryParam` should be used in fields, not in methods.                                                                        
        at org.jboss.resteasy.reactive.server.processor.ServerEndpointIndexer.handleBeanParam(ServerEndpointIndexer.java:303)                                                                                                                                                       
        at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:663)                                                                                                                                                              
        ... 13 more

How to Reproduce?

Reproducer:

beanparam-no-field.zip

unzip
mvn clean test

Output of uname -a or ver

MINGW64_NT-10.0-26100 NANBCHL9NG3 3.3.6-341.x86_64 2022-09-05 20:28 UTC x86_64 Msys

Output of java -version

openjdk 21.0.5 2024-10-15 LTS OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.5+11 (build 21.0.5+11-LTS, mixed mode, sharing)

Quarkus version or git rev

3.21.4

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

Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39) Maven home: C:\eclipse\tools\java\maven Java version: 21.0.5, vendor: Eclipse Adoptium, runtime: C:\eclipse\tools\java\21 Default locale: de_DE, platform encoding: UTF-8 OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions