11 Replies Latest reply on Jan 17, 2012 6:14 AM by lfryc

    a4j:push topic 'pushTest' is not configured

    healeyb

      I'm trying to get a4j:push working with CDI events on 4.1.0.Final. I have:

       

      <a4j:push address="pushTest"

                      ondataavailable="alert(event.rf.data)"/>

       

      @Inject

      @Push(topic = "pushTest")

      private Event<String> pushEvent;

       

      public void sendMessage() throws Exception {

              pushEvent.fire("let's see if this works 2");

      }

       

      web.xml

      <context-param>

              <param-name>org.richfaces.push.jms.disable</param-name>

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

      </context-param>

       

      pom.xml

      <dependency>

                  <groupId>org.atmosphere</groupId>

                  <artifactId>atmosphere-runtime</artifactId>

      </dependency>

       

      When I load the page containing a4j:push, I get an alert saying topic 'pushTest' is not configured. When

      I call the sendMessage() method the alert isn't opened by a4j:push. In the server log I see this output when

      I deploy the application:

       

      server log:

      INFO: SESSION CREATED ID: 901939c9b5c1f6777c0ca6a844d2

      INFO: Atmosphere is using async support: org.atmosphere.container.Servlet30CometSupportWithWebSocket running under container: "" with WebSocket enabled.

      INFO: Installed AtmosphereHandler null mapped to context-path: /*

      INFO: Installing Servlet null

      INFO: Installing Filter PushHandlerFilter

      INFO: Using broadcaster class: org.atmosphere.cpr.DefaultBroadcaster

      INFO: Atmosphere Framework 0.8.0-RC1 started.

       

      Is there any additional configuration required? I'm using glassfish 3.1.1 and have enabled comet.

       

      Update: I've added a simple listener and changed the code to use HelloEvent, and the event is getting

      fired successfully, so there must be something I'm missing on the a4j:push side of things.

       

      @Stateless

      public class HelloListener {

          public void listenToHello(@Observes HelloEvent helloEvent){

              SQLog.log("HelloEvent: " + helloEvent.getMessage());

          }

      }

       

      Update 2: when the page containing a4j:push loads I get the javascript alert box with the 'pushTest is not

      configured' message referred to above, I ok this an then see this error in the javascript console (chrome browser):

       

      1. GET https://localhost:8181/uk.co.sportquest_SportQuest_war_1.0.0/rfRes/org.richfaces.resource.PushResource.xhtml?__richfacesPushAsync=1&pushSessionId=a0c5e133-80a9-4310-ae6c-f37e3c4c8964 500 (Internal Server Error)
        1. executeRequestjquery-atmosphere.js.xhtml:281
        2. subscribejquery-atmosphere.js.xhtml:91
        3. richfaces.Push.pushSessionIdRequestHandlerpush.js.xhtml:112
        4. jQuery.extend._Deferred.deferred.resolveWithjquery.js.xhtml:1016
        5. donejquery.js.xhtml:7247
        6. jQuery.ajaxTransport.send.callbackjquery.js.xhtml:8028

       

      Thanks,

      Brendan.

        • 1. Re: a4j:push topic 'pushTest' is not configured
          healeyb

          bump - Hi, I'm keen to know if I'm looking at a Glassfish/Weld problem here, or a more general issue.

          Is anyone using a4j:push with 4.1.0.Final, if so with CDI events?

           

          Regards,

          Brendan.

          • 2. Re: a4j:push topic 'pushTest' is not configured
            iabughosh

            Hi Brendan,

            I faced the same problem, take a look at this :

            https://community.jboss.org/wiki/UsingRichFaces41PushCDITopicContextForNon-mavenBasedProjects

             

            regards.

            • 3. Re: a4j:push topic 'pushTest' is not configured
              healeyb

              Thanks Ibrahim, this is very helpful. I still have a problem because I'm running into this IllegalArgumentException:

               

              WARNING: StandardWrapperValve[FacesServlet]: PWC1406: Servlet.service() for servlet FacesServlet threw exception

              java.lang.IllegalArgumentException

                        at org.richfaces.resource.PushResource.encode(PushResource.java:85)

                        at org.richfaces.resource.UserResourceWrapperImpl.encode(UserResourceWrapperImpl.java:188)

                        at org.richfaces.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:222)

                        at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:125)

                        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:591)

                        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)

                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)

                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)

                        at uk.co.sportquest.jsfbeans.helper.CacheFilterStatic.doFilter(CacheFilterStatic.java:138)

                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)

                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)

               

               

              Any ideas anyone? It's not exactly easy to use is it?

              • 4. Re: a4j:push topic 'pushTest' is not configured
                iabughosh

                is it working now and throws this exception ?, are you calling pushEvent.fire from EJB context ?, pleasae post your bean and xhtml page.

                 

                also check this, i have some doubt about your filter (uk.co.sportquest.jsfbeans.helper.CacheFilterStatic.doFilter(CacheFilterStatic.java:138)) :

                http://stackoverflow.com/questions/7607780/java-jsf-strange-error-warning-standardwrappervalve-pwc1406-servlet-service

                • 5. Re: a4j:push topic 'pushTest' is not configured
                  healeyb

                  Hi Ibrahim, this is what I've got:

                   

                  <a4j:log/>

                  <h:outputText id="uid" value="uid: #{leagueMgrFixturesView.userIdentifier}"/>

                  <a4j:push address="#{leagueMgrFixturesView.userIdentifier}@pushCdi"

                            onerror="alert('error: ' + event.rf.data)"

                            ondataavailable="alert('data: ' + event.rf.data)">

                     <a4j:ajax event="dataavailable"/>

                  </a4j:push>

                  <a4j:commandButton value="push" action="#{leagueMgrFixturesView.sendMessage}"/>

                   

                  and the java:

                   

                  private static final String CDI_PUSH_TOPIC = "pushCdi";

                      private String userIdentifier;

                      @Inject

                      @Push(topic = CDI_PUSH_TOPIC, subtopic = "#{leagueMgrFixturesView.userIdentifier}")

                      private javax.enterprise.event.Event<String> pushEvent;

                   

                      @PostConstruct

                      public void init() {

                   

                          if (userIdentifier == null) {

                              userIdentifier = UUID.randomUUID().toString().replace("-", "");

                          }

                   

                          TopicsContext topicsContext = TopicsContext.lookup();

                          topicsContext.getOrCreateTopic(new TopicKey(CDI_PUSH_TOPIC, userIdentifier));

                      }

                   

                   

                      public void sendMessage() throws Exception {

                          Log.log("sendMessage");

                          pushEvent.fire("a test message");

                          //pushEvent.fire(new HelloEvent("TEST"));

                      }

                   

                  Regards,

                  Brendan.

                  • 6. Re: a4j:push topic 'pushTest' is not configured
                    iabughosh

                    did u check your filter code (uk.co.sportquest.jsfbeans.helper.CacheFilterStatic.doFilter(CacheFilterStatic.java:138)) : ?

                     

                    see this link for more information:

                    http://stackoverflow.com/questions/7607780/java-jsf-strange-error-warning-standardwrappervalve-pwc1406-servlet-service

                    • 7. Re: a4j:push topic 'pushTest' is not configured
                      healeyb

                      I did, the filter simply sets headers and calls chain.doFilter(req,res); - but I'll try without it just to be sure...

                      • 8. Re: a4j:push topic 'pushTest' is not configured
                        healeyb

                        I've just tried with the filter removed but still get the exception. I found two other posts on here from people with the same

                        problem, but no obvious solution. Hmmmm

                        • 9. Re: a4j:push topic 'pushTest' is not configured
                          lfryc

                          Hi Brendan, as I said in similar topic [1],

                           

                          the problem is the "pushTopic" is not propagated to the server.

                           

                          It should not happen in your code, unless your <a4j:push address="" />.

                           

                          It would be great if you could provide me maven app reproducing your issue so I can identify what's the problem.

                           

                          [1] https://community.jboss.org/message/646996#646996

                          • 10. Re: a4j:push topic 'pushTest' is not configured
                            healeyb

                            After a fair bit of messing about I've got it working and here, as far as I can tell, is everything relevant to getting

                            this working. A few points to bear in mind:

                             

                            1. I'm using a servlet v3 container (web.xml: web-app version="3.0") so don't need to declare the push servlet

                                explicitly in web.xml, but you might need to.

                             

                            2. I've seen some examples of a PushFilter in web.xml, this definitely was causing me problems and I only got

                                it working after removing this.

                             

                            3. I've seen it suggested to use this in the web.xml but I haven't needed to:

                             

                               <context-param>

                                    <param-name>org.richfaces.push.handlerMapping</param-name>

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

                               </context-param>

                             

                            4. There seems to be a problem with Atmosphere version later than (not including) 0.8.0-RC1

                                 that causes a NoClassDefFound error for WebSockets (something like that anyway). A big

                                 thanks to Vadim Si for figuring this out. The latest version 0.8.2 doesn't work.

                             

                            5. The lines relating to topicsContext in the java file are needed - that's what causes the "topic

                                 'topic-name' is not configured error". These are missing from the showcase example, but are

                                referenced in the component guide.

                             

                            Regards,

                            Brendan.

                             

                            pom.xml

                             

                            <dependency>

                                        <groupId>org.atmosphere</groupId>

                                        <artifactId>atmosphere-runtime</artifactId>

                                        <version>0.8.0-RC1</version>

                                        <type>jar</type>

                            </dependency>

                             

                            domain.xml

                             

                            <jvm-options>-Dcom.sun.grizzly.http.asyncwrite.enabled=true</jvm-options>

                            <jvm-options>-Dcom.sun.grizzly.http.asyncwrite.maxBufferPoolSize=10000</jvm-options>

                             

                            web.xml

                             

                            <context-param>

                                    <param-name>org.richfaces.push.jms.disable</param-name>

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

                                </context-param>

                                <context-param>

                                    <param-name>org.atmosphere.useBlocking</param-name>

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

                            </context-param>

                            <servlet>

                                    <description>AtmosphereServlet</description>

                                    <servlet-name>AtmosphereServlet</servlet-name>

                                    <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>

                                    <async-supported>true</async-supported>

                            </servlet>

                             

                            test.xhtml

                             

                            <h:outputText id="uid" value="uid: #{testBean.userIdentifier}"/>

                            <a4j:push address="#{testBean.userIdentifier}@pushCdi"

                                           onerror="alert('error: ' + event.rf.data)"

                                           ondataavailable="alert('data: ' + event.rf.data)">

                                <a4j:ajax event="dataavailable"/>

                            </a4j:push>

                             

                            TestBean.java

                               

                            @ViewScoped

                            public class TestBean implements Serializable {

                             

                                private static final String CDI_PUSH_TOPIC = "pushCdi";

                                private String userIdentifier;

                                @Inject

                                @Push(topic = CDI_PUSH_TOPIC, subtopic = "#{testBean.userIdentifier}")

                                private javax.enterprise.event.Event<String> pushEvent;

                             

                                @PostConstruct

                                public void init() {

                             

                                    if (userIdentifier == null) {

                                        userIdentifier = UUID.randomUUID().toString().replace("-", "");

                                    }

                             

                                    TopicsContext topicsContext = TopicsContext.lookup();

                                    topicsContext.getOrCreateTopic(new TopicKey(CDI_PUSH_TOPIC, userIdentifier));

                                }

                             

                                public void sendMessage() throws Exception {

                                    Log.log("sendMessage");

                                    pushEvent.fire("a test message");

                                }

                             

                                // add getters & setters

                            • 11. Re: a4j:push topic 'pushTest' is not configured
                              lfryc

                              Please refer to Starting with RichFaces Push on Various Servlet Containers .

                               

                              I would appreciate your feedback there.