Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-2105

org.jboss.resteasy.annotations.jaxrs.*Param annotations don't work with both proxy and MP REST client

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.0.0.Beta7, 3.6.3.Final
    • 3.6.2.Final
    • None
    • None

      org.jboss.resteasy.annotations.jaxrs.*Param annotations don't work with both proxy and MP REST client.

      Bug is probably in ProcessorFactory#createProcessor method. This method needs to handle both spec and RESTEasy annotations.

      Example:
      Client side:

      import org.jboss.resteasy.annotations.jaxrs.QueryParam;
      import javax.ws.rs.GET;
      import javax.ws.rs.Path;
      @Path("/")
      public interface Proxy {
          @Path("a")
          @GET
          String deploy(@QueryParam("a") String a);
      }
      
          public static void main(String[] args) throws Exception {
              try {
                  Proxy proxy = new ResteasyClientBuilder().build().target("http://localhost:8080/jaxrs-wf").proxy(Proxy.class);
                  System.out.println(proxy.deploy("a"));
              } catch (RuntimeException e) {
                  e.printStackTrace();
              }
      
              System.out.println("==============");
      
              try {
                  Proxy mpRestClient = RestClientBuilder.newBuilder().baseUrl(new URL("http://localhost:8080/jaxrs-wf")).build(Proxy.class);
                  System.out.println(mpRestClient.deploy("a"));
              } catch (RuntimeException e) {
                  e.printStackTrace();
              }
          }
      

      Server side:

      @Path("/")
      public class ClassResource {
          @Path("a")
          @GET
          public String rolesAllowed(@QueryParam("a") String a) {
              return a;
          }
      }
      

      Output:

      java.lang.RuntimeException: RESTEASY004590: You must define a @Consumes type on your client method or interface, or supply a default
      	at org.jboss.resteasy.client.jaxrs.internal.proxy.processors.ProcessorFactory.createProcessor(ProcessorFactory.java:150)
      	at org.jboss.resteasy.client.jaxrs.internal.proxy.processors.ProcessorFactory.createProcessors(ProcessorFactory.java:59)
      	at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.<init>(ClientInvoker.java:88)
      	at org.jboss.resteasy.client.jaxrs.ProxyBuilder.createClientInvoker(ProxyBuilder.java:95)
      	at org.jboss.resteasy.client.jaxrs.ProxyBuilder.proxy(ProxyBuilder.java:69)
      	at org.jboss.resteasy.client.jaxrs.ProxyBuilder.build(ProxyBuilder.java:152)
      	at org.jboss.resteasy.client.jaxrs.internal.ClientWebTarget.proxy(ClientWebTarget.java:93)
      	at com.resteasy.test.App.main(App.java:22)
      ==============
      java.lang.reflect.UndeclaredThrowableException
      	at com.sun.proxy.$Proxy17.deploy(Unknown Source)
      	at com.resteasy.test.App.main(App.java:32)
      Caused by: java.lang.reflect.InvocationTargetException
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      	at org.jboss.resteasy.client.microprofile.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:92)
      	... 2 more
      Caused by: javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request
      	at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:321)
      	at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:439)
      	at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invokeSync(ClientInvoker.java:148)
      	at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:112)
      	at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:76)
      	at com.sun.proxy.$Proxy16.deploy(Unknown Source)
      	... 7 more
      Caused by: javax.ws.rs.ProcessingException: RESTEASY004565: A GET request cannot have a body.
      	at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.loadHttpMethod(ApacheHttpClient4Engine.java:503)
      	at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:310)
      	... 12 more
      

              mmarusic Marek Marusic (Inactive)
              mkopecky@redhat.com Marek Kopecky
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: