Search code examples
jsf-2primefacespush-notificationwildfly-9primefaces-push

Primefaces Push notify example does not work with wildfly 9.0.2


I tried to do the notify example of primefaces push in wildfly 9.0.2 but does not work, I searched the error but the answers I've found not helped me, here is my code:

and thanks for the advice

index:

<h:head>
    <title>Facelet Title</title>
</h:head>
<h:body>
    <p:growl widgetVar="growl" showDetail="true" />

    <h:form>
        <h:panelGrid columns="2">
            <p:outputLabel for="summary" value="Summary: " /> 
            <p:inputText id="summary" value="#{notifyView.summary}" required="true" />

            <p:outputLabel for="detail" value="Detail: " /> 
            <p:inputText id="detail" value="#{notifyView.detail}" required="true" />
        </h:panelGrid>

        <p:commandButton value="Send" actionListener="#{notifyView.send}" />
    </h:form>

    <p:socket onMessage="handleMessage" channel="/notify" />

    <script type="text/javascript">
        function handleMessage(facesmessage) {
            facesmessage.severity = 'info';

            PF('growl').show([facesmessage]);
        }
    </script>
</h:body>

NotifyView.java:

public class NotifyView {

private final static String CHANNEL = "/notify";

private String summary;

private String detail;

public String getSummary() {
    return summary;
}
public void setSummary(String summary) {
    this.summary = summary;
}

public String getDetail() {
    return detail;
}
public void setDetail(String detail) {
    this.detail = detail;
}

public void send() {
    EventBus eventBus = EventBusFactory.getDefault().eventBus();
    eventBus.publish(CHANNEL, new FacesMessage(StringEscapeUtils.escapeHtml3(summary), StringEscapeUtils.escapeHtml3(detail)));
}}

NotifyResource.java:

@PushEndpoint("/notify")

public class NotifyResource {

@OnMessage(encoders = {JSONEncoder.class})
public FacesMessage onMessage(FacesMessage message) {
    return message;
}

}

And finally web.xml:

<servlet>
    <servlet-name>Push Servlet</servlet-name>
    <servlet-class>org.primefaces.push.PushServlet</servlet-class>
    <async-supported>true</async-supported>
</servlet>
<servlet-mapping>
    <servlet-name>Push Servlet</servlet-name>
    <url-pattern>/primepush/*</url-pattern>
</servlet-mapping>

I use Wildfly 9.0.2, Primefaces 5.2, commons-lang3-3.4 and try with atmosphere-runtime versions: 2.1.7, 2.4.0-RC6 and 2.4.5

The log error:

14:31:29,771 ERROR [io.undertow.request] (default task-24) UT005023: Exception handling request to /Primefaces2_1/primepush/notify: java.lang.NoSuchMethodError: org.atmosphere.cpr.AtmosphereServlet.configureFramework(Ljavax/servlet/ServletConfig;Z)Lorg/atmosphere/cpr/AtmosphereServlet; at org.primefaces.push.PushServlet.configureFramework(PushServlet.java:67) at org.primefaces.push.PushServlet.configureFramework(PushServlet.java:36) at org.atmosphere.cpr.AtmosphereServlet.init(AtmosphereServlet.java:80)...


Solution

  • Finally I found a solution:

    Using atmosphere-runtime-native and jboss-as-websockets libraries works.

    thanks for help to Xtreme Biker