Ошибка рукопожатия в веб-сокете в консоли браузера для f: websocket jsf-2.3 WebSphere liberty - PullRequest
0 голосов
/ 18 июня 2019

f: websocket функция JSF-2.3 в WebSphere свобода выбрасывает ошибка рукопожатия в консоли браузера

Я пытаюсь использовать функцию f: websocket в JSF-2.3 на WebSphere Liberty и следовал примеру, доступному в Интернете, но для другого сервера. https://blog.payara.fish/jsf-2.3-the-websocket-quickstart-under-payara-server

Ниже приведены списки файлов

  1. server.xml
<server description="new server">
  <!-- Enable features -->
  <featureManager>
    <feature>ejbLite-3.2</feature>
    <feature>jaxrs-2.1</feature>
    <feature>jaxws-2.2</feature>
    <feature>localConnector-1.0</feature>
    <feature>jpa-2.2</feature>
    <feature>cdi-2.0</feature>
    <feature>jsf-2.3</feature>
    <feature>websocket-1.1</feature>
    <feature>servlet-4.0</feature>
    <feature>beanValidation-2.0</feature>
  </featureManager>

  <applicationManager autoExpand="true" />
  <applicationMonitor updateTrigger="mbean" />
  <cdi12 enableImplicitBeanArchives="false" />
  <webApplication id="WebSocket" location="WebSocket.war" name="WebSocket" />
</server>
  1. web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="4.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd">
  <context-param>
    <param-name>javax.faces.ENABLE_CDI_RESOLVER_CHAIN</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.ENABLE_WEBSOCKET_ENDPOINT</param-name>
    <param-value>true</param-value>
  </context-param>
  <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>*.xhtml</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
  </welcome-file-list>
</web-app>
  1. index.xhtml
<!DOCTYPE html>
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
    <title>Hello World JSF 2.3</title>
      <script type="text/javascript">
      function socketListener(message, channel, event) {
        console.log("Hello world!");
        document.getElementById("clockId").innerHTML += message + "<br/>";
      }
    </script>
</h:head>
<h:body>
    <h:form>
    <h:commandButton value="Clock" action="#{pushBean.clockAction()}">
      <f:ajax />
    </h:commandButton>
  </h:form>
  <f:websocket channel="clock" onmessage="socketListener" scope="session" />
  <hr />
  <div id="clockId"></div>
</h:body>
</html>

4.PushBean.java

package com.notify.sample;

import java.io.Serializable;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.enterprise.context.RequestScoped;
import javax.faces.push.Push;
import javax.faces.push.PushContext;
import javax.inject.Inject;
import javax.inject.Named;

@Named
@RequestScoped
public class PushBean implements Serializable {

  private static final Logger LOG = Logger.getLogger(PushBean.class.getName());

  @Inject
  @Push(channel = "clock")
  private PushContext push;


  public void clockAction() {
    Calendar now = Calendar.getInstance();
    String time = now.get(Calendar.HOUR_OF_DAY) + ":" + now.get(Calendar.MINUTE) + ":" + now.get(Calendar.SECOND);
    LOG.log(Level.INFO, "Time: {0}", time);
    System.out.println(time);
    push.send(time);
  }
}
  1. лица-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
    version="2.3">

    <!-- Config here. -->
</faces-config>

6.beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" 
  bean-discovery-mode="all">
</beans>

Ошибка: нет ошибки, но она не работает Исключено: значение, отправленное с сервера по адресу clockId

...