1 Reply Latest reply on Sep 7, 2013 3:42 PM by csa

    Bug in Errai? Not sending String parameter (jax-rs)

    xybrek

      Here is my code for the Errai RPC which I think have a bug:

       

       

          service.call(new RemoteCallback<MyModel>() {

           @Override

           public void callback(MyModel model) {

         

           }

           }, new ErrorCallback() {

         

           @Override

           public boolean error(Message message, Throwable throwable) {

           Window.alert("Error");

           return false;

           }

           }).getMyModelByHash("ja");

       

       

      The implementation class is annotated with `@SessionScoped` and the method looks like this:

       

       

          @Override

          @GET

          @Consumes("text/plain")

          @Produces("application/json")

          public MyModel getMyModelByHash(String hash) {

           LOG.info("Fetching item with hash=" + hash);

           return null;

          }

       

       

      The log only shows this `Fetching item with hash=`

       

       

      So I think this is a bug in Errai that it can't send String parameter?

        • 1. Re: Bug in Errai? Not sending String parameter (jax-rs)
          csa

          Hi,

           

          No, this is not a bug in Errai. You're using a non-annotated parameter which means you want the parameter's value to be part of the request body. GET and HEAD requests are not supposed to carry request bodies that affect the server's response. In fact, XMLHttpRequest will not send the request body for GET and HEAD requests: http://www.w3.org/TR/XMLHttpRequest/#the-send()-method

           

          You either need to annotate the parameter with @PathParam, @QueryParam, etc. (that's what I'd recommend) or use @POST or @PUT instead, if you prefer using the request body to carry that information.

           

          Cheers,

          Christian