3 Replies Latest reply on Jun 18, 2012 12:17 PM by gregst

    AJAX Push Error - "Service Tracker has not been initialized"

    gregst

      AJAX push working until cdi extension added and now there is this exception,

       

      javax.faces.FacesException: Service Tracker has not been initialized

      at org.richfaces.application.ServiceTracker.getServicesFactory(ServiceTracker.java:100)

      at org.richfaces.application.ServiceTracker.getService(ServiceTracker.java:81)

      at org.richfaces.application.push.TopicsContext.lookup(TopicsContext.java:79)

      ...

       

      The cdi extension is given in the meta-inf/services/javax.enterprise.inject.spi.Extension file and is working.

       

      What could be wrong to cause this problem?

        • 1. Re: AJAX Push Error - "Service Tracker has not been initialized"
          gregst

          There is an external thread (not the faces context thread) that is publishing a message to the topic context and this is where the exception occurs.  When publishing the message in the faces context thread there is no exception.

           

          Without the cdi services extension, the context class loader is the same for the faces context thread and the external thread.  With the cdi services extension, the context class loaders are different and there is no service factory set for the external thread context class loader.

           

          To publish with an external thread, push is initialized on startup.  Is there something more to make this work with the cdi service extension?

          • 2. Re: AJAX Push Error - "Service Tracker has not been initialized"
            lfryc

            The Push should be initialized at startup in order to ensure FacesContext is available in time of initializing Push Context.

             

            Then, when you are pushing messages, you need to ensure you are pushing using Web application's class loader, the shared classloaders won't have Push Context visible.

             

            ----

             

            Which container are you running?

            • 3. Re: AJAX Push Error - "Service Tracker has not been initialized"
              gregst

              Running in JBoss 7.1.1 and have the "org.richfaces.push.initializeOnStartup" enabled.

               

              However, the problem is as you indicated where this external thread is not "pushing using Web application's class loader".  After seeing this, the external thread is now using another thread created with the web application class loader and having the required push context.

               

              This CDI service extension was added to eagerly intantiate the application scoped bean containing this external thread.  Even though it was annotated with @Startup, the application bean was instantiated with the web application class loader when injected in a session bean.

               

              After the service extension was added to eagerly instantiate the application bean,  the bean is now created with the enterprise application class loader.  In this case, the push does not work from this external thread because it does not have the push context.

               

              Given the way this is working, probably will look at using JMS for pushing instead of this "push context".

               

              Thanks for the help.