服务器端Omnifaces推送。 PushContext为null

时间:2019-06-07 11:05:10

标签: java jsf push omnifaces

我的问题是关于服务器端 Omnifaces Push。因此,我试图在项目上集成Omnifaces Push,但是当我尝试发送消息时,PushContext实例出现了问题(PushContext实例为null)。

技术堆栈

  • Tomcat 9.0.22
  • 3.2.1级
  • JSF 2.2
  • Primefaces 6.2
  • Omnifaces 2.7.1
  • cdi api 2.0
  • 焊接servlet阴影3.0.5.Final

我有一个CDI容器,我想注入一些PushContext实例(不同的推送通道),但是这些实例没有被注入或被错误地注入为null。当我调用 notificar 方法时, pushInicio 为空。

PS C:\> Remove-AzResource -Name "alert for rg" -ResourceType Microsoft.AlertsManagement/actionRules

Confirm
Are you sure you want to delete the following resource:
/subscriptions/XXXX/providers/Microsoft.AlertsManagement/actionRules/alert%20for%20rg
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
Remove-AzResource : ResourceNotFound : The Resource 'Microsoft.AlertsManagement/actionRules/alert for rg' under resource gr
oup '<null>' was not found.
At line:1 char:1
+ Remove-AzResource -Name "alert for rg" -ResourceType Microsoft.Alerts ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : CloseError: (:) [Remove-AzResource], ErrorResponseMessageException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.RemoveAzureResourceCmdlet

配置

web.xml

@Named
@Startup
public class ControladorMedidas
        implements Serializable {
    @Inject
    @Push(channel = "inicio")
    private PushContext pushInicio;

    @Inject
    @Push(channel = "centro")
    private PushContext pushCentro;

    ...
    private void notificar() {
        // pushInicio -> null
        pushInicio.send("some message");
    }
}

beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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-app_3_0.xsd">
    <resource-env-ref>
        <!-- Enable Weld CDI, also needs META-INF/context.xml entry -->
        <resource-env-ref-name>BeanManager</resource-env-ref-name>
        <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
    </resource-env-ref>
    <!-- ... -->
    <!-- Configuracion PUSH OmniFaces -->
    <context-param>
        <param-name>org.omnifaces.SOCKET_ENDPOINT_ENABLED</param-name>
        <param-value>true</param-value>
    </context-param>
    <!-- ... -->
</web-app>

context.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="annotated"
>
</beans>

似乎OmniFaces已正确加载,因为Tomcat跟踪以下行:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/servicios">
    <Resource
            name="BeanManager"
            auth="Container"
            type="javax.enterprise.inject.spi.BeanManager"
            factory="org.jboss.weld.resources.ManagerObjectFactory"
    />
</Context>

另一方面,Tomcat不会引发任何与Omnifaces相关的错误。

谢谢。

0 个答案:

没有答案