2016-05-17 41 views
-1

我试图与WebSphere 8.5以下运行Primefaces Nofity是文件和错误的细节,只是坚持做任何事情在IDE控制台只是浏览器的控制台错误和对任何错误:插座都Primefaces |推送|通知| Websphere 8.5 |气氛运行

不触发下面的代码效果很好使用Tomcat,但不与网络的球体

A)的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> 
    <display-name>Notify</display-name> 
    <welcome-file-list> 
     <welcome-file>index.jsp</welcome-file> 
    </welcome-file-list> 



    <servlet> 
     <servlet-name>Faces Servlet</servlet-name> 
     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>*.jsf</url-pattern> 
    </servlet-mapping> 

<servlet> 
     <servlet-name>Push Servlet</servlet-name> 
     <servlet-class>org.primefaces.push.PushServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
      <init-param> 
     <param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name> 
     <param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value> 
    </init-param> 
    <init-param> 
     <param-name>org.atmosphere.annotation.packages</param-name> 
     <param-value>org.primefaces.push.annotation</param-value> 
     </init-param> 
    <init-param> 
     <param-name>org.atmosphere.cpr.broadcasterClass</param-name> 
     <param-value>org.atmosphere.cpr.DefaultBroadcaster</param-value> 
    </init-param> 
    <init-param> 
     <param-name>org.atmosphere.cpr.packages</param-name> 
     <param-value>com.notify.sample</param-value> 
    </init-param> 
    <init-param> 
     <param-name>org.atmosphere.cpr.sessionSupport</param-name> 
     <param-value>true</param-value> 
    </init-param> 
     <async-supported>true</async-supported> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>Push Servlet</servlet-name> 
     <url-pattern>/primepush/*</url-pattern> 
    </servlet-mapping> 

</web-app> 

B)面向-config.xml中作为

<?xml version="1.0" encoding="utf-8"?> 
<faces-config 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-facesconfig_2_0.xsd" 
    version="2.0"> 


</faces-config> 

C)NotifyResource.java

package com.notify.sample; 


import javax.faces.application.FacesMessage; 

import org.primefaces.push.EventBus; 
import org.primefaces.push.RemoteEndpoint; 
import org.primefaces.push.annotation.OnClose; 
import org.primefaces.push.annotation.OnMessage; 
import org.primefaces.push.annotation.OnOpen; 
import org.primefaces.push.annotation.PushEndpoint; 
import org.primefaces.push.impl.JSONEncoder; 

@PushEndpoint("/notify") 
public class NotifyResource { 

    @OnOpen 
    public void onOpen(RemoteEndpoint r, EventBus e) { 
    } 

    @OnClose 
    public void onClose(RemoteEndpoint r, EventBus e) { 
    } 

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

} 

d)NotifyView.java

package com.notify.sample; 

import javax.faces.application.FacesMessage; 
import javax.faces.bean.ManagedBean; 
import javax.faces.bean.RequestScoped; 

import org.apache.commons.lang.StringEscapeUtils; 
import org.primefaces.push.EventBus; 
import org.primefaces.push.EventBusFactory; 

@ManagedBean 
@RequestScoped 
public class NotifyView { 

    private final static String CHANNEL = "/notify"; 

    /** The Constant LOGGER. */ 

    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.escapeHtml(summary), StringEscapeUtils.escapeHtml(detail))); 
    } 
} 

E)notify.xhrml

<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:csxc="http://java.sun.com/jsf/composite/csxcomponent" 
    xmlns:p="http://primefaces.org/ui"> 
<h:head> 
    <script type="text/javascript"> 
     function handleMessage(facesmessage) { 
      facesmessage.severity = 'info'; 

      PF('growl').show([facesmessage]); 
     } 
</script> 
</h:head> 
<h:body> 
    <center> 
    <p:panel header="Notify Form" style="width: 350;"> 
    <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" /> 

    </p:panel> 
    </center> 
</h:body> 
</html> 

F)WEB-INF/lib中

  1. commons-lang-2.4.jar
  2. 大气运行时2.3.1.jar
  3. JSF的api.jar文件
  4. JSF-impl.jar中
  5. JSTL-1.0.2.jar
  6. primefaces-5.2.10.jar
  7. SLF4J-简单1.6.1.jar
  8. slf4j.api-1.6.1.jar

G)的index.jsp

<jsp:forward page="notify.jsf"></jsp:forward> 

浏览器控制台错误

Tue May 17 2016 22:11:52 GMT+0530 (India Standard Time) Atmosphere: unload event push.js.jsf:1:39484 
GET 
http://localhost:9080/app_notify/primepush/notify [HTTP/1.1 404 Not Found 5ms] 
Firefox can't establish a connection to the server at ws://localhost:9080/app_notify/primepush/notify?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.9-javascript&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&X-atmo-protocol=true. push.js.jsf:1:12442 
Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent). push.js.jsf:1:39484 
Websocket closed, wasClean: false push.js.jsf:1:39484 
Websocket failed. Downgrading to Comet and resending push.js.jsf:1:39484 
GET 
XHR 
http://localhost:9080/app_notify/primepush/notify [HTTP/1.1 404 Not Found 2ms] 
GET 
XHR 
http://localhost:9080/app_notify/primepush/notify [HTTP/1.1 404 Not Found 1ms] 
GET 
XHR 
http://localhost:9080/app_notify/primepush/notify [HTTP/1.1 404 Not Found 2ms] 
GET 
XHR 
http://localhost:9080/app_notify/primepush/notify [HTTP/1.1 404 Not Found 2ms] 
GET 
XHR 
http://localhost:9080/app_notify/primepush/notify [HTTP/1.1 404 Not Found 2ms] 
GET 
XHR 
http://localhost:9080/app_notify/primepush/notify [HTTP/1.1 404 Not Found 2ms] 
+0

哪个WebSphere版本?这是使用WebSphere Liberty吗? – ebullient

+0

感谢您的回复,我正在使用WebSphere Application Server V8.5而不是自由版本 – djCode

+0

我还需要提出另一个问题,因为我不太了解这个堆栈:是否提供websocket实现的氛围?传统v8.5不支持websockets。我很想知道这个应用程序是否适用于WebSphere Liberty(可在http://wasdev.net上获得)。使用jsf-2.2和websocket-1.1功能,这意味着你可以从web-inf/lib中删除很多。 (明白这可能比你想要让我的好奇心更加变化。;)) – ebullient

回答

0

因此,作为回答,我们可以庆祝,我认为问题的症结在于气氛(正确的,在我看来)为依托的WebSockets支持基础服务器上。

该应用程序适用于WebSphere Liberty,它支持WebSockets。

它不适用于WebSphere传统v8.5,它不适用。

如果使用WebSphere的传统配置文件很重要,那么WebSphere传统版支持WebSockets可用于测试版。