1 Reply Latest reply on Mar 12, 2014 8:20 PM by csa

    Errai Jax-RS not firing

    xybrek

      I really dont understand why errai jax-rs is not firing:

       

       

      **Usage**

       

       

          @Inject

          private Caller<ApiService> myService;

       

       

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

                      @Override

                      public void callback(MyModel result) {

                              t.cancel();

                              GWT.log("Response from server: " + result);

                          }

                      }).create(model);

       

       

      **Service**

       

       

          @Path("api")

          public interface ApiService {

              @POST

              @Consumes("application/json")

              @Produces("application/json")

              public MyModel create(MyModel model);

          }

       

       

          public class ApiServiceResource implements ApiService {

         

              private final InternalService internalService;

         

              @Inject // Guice

              public ApiServiceResource(InternalService internalService){

                  this.internalService = internalService;

              }

         

              @Override

              public MyModel create(MyModel model) {

                  System.out.println("Creating model: " + model.toString());

                  return internalService.createModel(model);

              }

          }

       

       

       

       

      **gwt.xml settings:**

       

       

             <inherits name="org.jboss.errai.common.ErraiCommon" />

             <inherits name="org.jboss.errai.bus.ErraiBus" />

             <inherits name="org.jboss.errai.ioc.Container" />

             <inherits name="org.jboss.errai.ui.UI" />

             <inherits name="org.jboss.errai.databinding.DataBinding" />

             <inherits name="org.jboss.errai.enterprise.CDI" />

             <inherits name="org.jboss.errai.enterprise.Jaxrs" />

             <inherits name="org.jboss.errai.ui.nav.Navigation"/>

       

       

      **index.html setting:**

       

       

          <script type="text/javascript">erraiBusRemoteCommunicationEnabled = false;</script>

       

       

      **web.xml**

       

       

          <?xml version="1.0" encoding="UTF-8"?>

          <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

         

              <!-- GAE-Shiro -->

              <context-param>

                 <param-name>user-base-url</param-name>

                 <param-value>/user/admin</param-value>

              </context-param>

         

              <context-param>

                  <param-name>static-base-url</param-name>

                  <param-value></param-value>

              </context-param>

         

              <filter>

                  <filter-name>guiceFilter</filter-name>

                  <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>

              </filter>

         

              <filter-mapping>

                  <filter-name>guiceFilter</filter-name>

                  <url-pattern>/*</url-pattern>

                  <dispatcher>REQUEST</dispatcher>

                  <dispatcher>FORWARD</dispatcher>

                  <dispatcher>INCLUDE</dispatcher>

              </filter-mapping>

         

              <listener>

                  <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>

              </listener>

        

              <mime-mapping>

                  <extension>manifest</extension>

                  <mime-type>text/cache-manifest</mime-type>

              </mime-mapping>

         

              <welcome-file-list>

                  <welcome-file>index.html</welcome-file>

              </welcome-file-list>  

             

              <!-- JBoss Resteasy -->

             

              <context-param>

                  <param-name>resteasy.guice.modules</param-name>

                  <param-value>com.myapp.server.guice.ServeModule</param-value>

              </context-param>

         

            <context-param>

            <param-name>resteasy.providers</param-name>

            <param-value>org.jboss.errai.jaxrs.ErraiProvider</param-value>

            </context-param>

         

              <servlet>

                  <servlet-name>ErraiServlet</servlet-name>

                  <servlet-class>org.jboss.errai.bus.server.servlet.DefaultBlockingServlet</servlet-class>

                  <load-on-startup>1</load-on-startup>

              </servlet>

         

              <servlet-mapping>

                  <servlet-name>ErraiServlet</servlet-name>

                  <url-pattern>*.erraiBus</url-pattern>

              </servlet-mapping>

           

              <listener>

          <listener-class>

          com.myapp.server.guice.CustomGuiceResteasyBootstrapServletContextListener

          </listener-class>

              </listener>

         

          <context-param> 

              <param-name>resteasy.servlet.mapping.prefix</param-name> 

              <param-value>/</param-value> 

            </context-param>

           

              <servlet>

                  <servlet-name>Resteasy</servlet-name>

                  <servlet-class>

                      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher

                  </servlet-class>

              </servlet>

         

              <servlet-mapping>

                  <servlet-name>Resteasy</servlet-name>

                  <url-pattern>/*</url-pattern>

              </servlet-mapping>   

         

          </web-app>

       

       

       

       

      **Guice ServeModule:**

       

       

          @Override

          protected void configureServlets() {

               bind(ApiService.class).to(ApiServiceResource.class).in(Scopes.SINGLETON)

          }

        • 1. Re: Errai Jax-RS not firing
          csa

          Hi,

           

          Two things you can do:

           

          1. Check your browser's network tab (chrome dev tools or Firebug) to look for errors and see where the requests are going.

          2. Provide an ErrorCallback at myService.call. It should give you more information about what goes wrong.

           

          Cheers,

          Christian