1 Reply Latest reply on Dec 10, 2013 11:15 AM by Jonathan Fuerth

    Wrong / Another Endpoint Method Is Executed With Errai Caller<>

    Charles Odili Apprentice

      Has anyone ever invoked a method on a Caller jax-rs endpoint and end up with another method in the endpoint been called, am having that right now?

      I am following the errai-tutorial, and I added a jax-rs expoint just like UserComplaintEndpoint. My endpoint defines (for now) two @POST methods.

       

      The problem is that when I invoke one of he endpoint's method, it is the other one that gets executed. Strangely!

       

      See code details here : http://ur1.ca/g651p

        • 1. Re: Wrong / Another Endpoint Method Is Executed With Errai Caller<>
          Jonathan Fuerth Master

          Hi Charles,

           

          The problem is that your two JAX-RS resource methods have the same path. Both are at /putme:

           

          @Path("/putme")
          public interface PutmeEndpoint {
          
                  @POST
                  @Consumes("application/json")
                  public Response addbundle(PutmeSubjectBundle bundle);
          
                  @POST
                  @Consumes("application/json")
                  public Response addsubject(PutmeSubject subject);
          
                  .... // had to comment the rest out even in my code.
          }
          

           

          You'll need to differentiate the methods by giving one (or both!) of them a different path name. Otherwise, when the POST request gets to the server, RestEasy won't know which method to invoke!

           

          For example:

           

          @Path("/putme")
          public interface PutmeEndpoint {
          
                  @POST
                  @Path("bundle")
                  @Consumes("application/json")
                  public Response addbundle(PutmeSubjectBundle bundle);
          
                  @POST
                  @Path("subject")
                  @Consumes("application/json")
                  public Response addsubject(PutmeSubject subject);
          
                  .... // had to comment the rest out even in my code.
          }
          

           

          Then one method handle requests to /putme/bundle and the other will handle requests to /putme/subject.

           

          Hope that helps.

           

          -Jonathan