4 Replies Latest reply on Dec 16, 2013 11:12 PM by Cristian Miranda

    Errai REST Service call

    Cristian Miranda Newbie

      Hi guys,


           I'm trying to implement some REST services in my application using Errai 2.4.3.Final following this doc: Errai JAX-RS - Errai - Project Documentation Editor


           I can not make it to work. When running the application in debug mode, I put a breakpoint in the service implementation and it never gets invoked.


           Here's my code:


      package app.client.shared.service;
      import java.util.List;
      import javax.ws.rs.GET;
      import javax.ws.rs.Path;
      import javax.ws.rs.Produces;
      import com.magick.models.shared.Strategy;
      public interface EnabledStrategies {
        public List<Strategy> listAllEnabledStrategies();


      package app.server.service;
      import java.util.List;
      import javax.inject.Inject;
      import app.client.shared.service.EnabledStrategies;
      import app.server.persistence.StrategyDAO;
      import com.magick.models.shared.Strategy;
      public class EnabledStrategiesImpl implements EnabledStrategies {
        private StrategyDAO strategyDAO;
        public List<Strategy> listAllEnabledStrategies() {
             return this.strategyDAO.getEnabledStrategies();


      and in the client side:


      private Caller<EnabledStrategies> enabledStrategies;
      enabledStrategies.call(new RemoteCallback<List<Strategy>>() {
                          public void callback(List<Strategy> strategies) {
                               // Do something with the strategies


      Am I missing something?



        • 1. Re: Errai REST Service call
          Christian Sadilek Master

          Hi Cristian,


          An easy way to find out what's wrong is to take a look at the request your browser sends when listAllEnabledStrategies() is invoked on the client. You can use FireBug (click on the Net tab) or in Chrome (View->Developer Tools->Network tab).


          You can also try to type the URL directly in your browser and check for the response.


          A mistake I can think of is not configuring the root path of your REST endpoint properly (see here for more details).




          1 of 1 people found this helpful
          • 2. Re: Errai REST Service call
            Cristian Miranda Newbie

            Cool, so after setting my REST endpoint this way:



            the URL would be: www.myapp.com/MyJaxRsEndpointPath/myServicePath??

            Should I add some additional configuration on my web.xml?


            • 3. Re: Errai REST Service call
              Christian Sadilek Master

              Yes. If you've started from the errai-tutorial project you will already have a configuration in there that registers all REST endpoints under /rest:



              There are multiple ways to configure RestEasy depending on what server you intend to use:

              RESTEasy JAX-RS




              • 4. Re: Re: Errai REST Service call
                Cristian Miranda Newbie

                Thanks! added the following to my web.xml and is working now... The only issue I'm having is that all the injected beans in my service are null. Is this because service is not being retrieved from the container? How could I solve this?


                    <!-- Auto scan REST service -->
                    <!-- this need same with resteasy servlet url-pattern -->


                Thank you again for replying so fast! you guys rock!