4 Replies Latest reply on Jan 21, 2014 2:50 AM by zime

    Service problem

    zime

      I'm evaluating Errai, so I'm creating an application to test several aspect.

      In this application I used both CDI, messaging and RPC as described in docs.

      CDI and RPC works correctly, but i have some problema with messagging.

       

      I create a service like that:

       

      @Service
      public class MyService implements MessageCallback {
      
      
        public void callback(Message message) {
        ...
        }
      }
      

       

      And i have this configuration in web.xml :

       

      <init-param>
         <param-name> service-locator </param-name >
         <param-value> org.jboss.errai.cdi.server.CDIServiceLocator </param-value >
      </init-param> 
      

       

      Calling from client with MessageBuilder is ok.

       

      Now i want, from callback, send a broadcast message to all client so I added the following code


      @Service
      public class MyService implements MessageCallback {
      
        private RequestDispatcher dispatcher;
      
         @Inject
         public MyService(RequestDispatcher dispatcher) {
           this.dispatcher = dispatcher;
         }
         
        public void callback(Message message) {
        
         ... 
      
       MessageBuilder.createMessage()
            .toSubject("BroadcastReceiver")
            .signalling()     
            .withValue(res)  
            .noErrorHandling()        
            .sendNowWith(dispatcher);    
        }
      

       

      When i call the service, i receive thsi exception:

       

      no subscribers to deliver to for subject: MyService

      org.jboss.errai.bus.client.api.base.NoSubscribersToDeliverTo: no subscribers to deliver to for subject: MyService

       

      If I add this configuration to web.xml

       

              <init-param>
                  <param-name> auto-discover-services </param-name >
                  <param-value> true</param-value >
              </init-param>
      

       

      no exception is thrown, but message is deliverde twice, and so the method is executed twice.

       

      What's wrong?

        • 1. Re: Service problem
          mbarkley

          Hi Simone,

           

          What version of Errai are you using? The CDIServiceLocator isn't in 3.0 or 2.4 . So if you're using one of those versions of Errai and you're using an EE6 container on the server, then just get rid of the service-locator and auto-discover-services parameters from your web.xml and everything should work.

           

          Cheers.

          • 2. Re: Service problem
            zime

            I use 2.4.3 version, in dev mode (so with jetty) and if i remove both parameter, i get the error i posted before: no subscribers to deliver to for subject:

             

            Just to try, i made a package to deploy under Jboss7 but i get the same problem.

            • 3. Re: Service problem
              mbarkley

              Hi Simone,

               

              A few other things you should check:

              • Do you have a beans.xml in your WEB-INF/ ?
              • Do you have an ErraiApp.properties (even if it's empty) in the default package of your project?

              For reference, here is our errai-tutorial project. It has a beans.xml here, and an ErraiApp.properties here.

              • 4. Re: Service problem
                zime

                I have bean.xml and also ErraiApp.properties .

                I think problem is in injection, if i remove this code:

                 

                @Inject 

                   public MyService(RequestDispatcher dispatcher) { 

                     this.dispatcher = dispatcher; 

                }


                i can call service, but i don't have dispatcher to send message to alla client.