我的问题是关于服务器端 Omnifaces Push。因此,我试图在项目上集成Omnifaces Push,但是当我尝试发送消息时,PushContext实例出现了问题(PushContext实例为null)。
我有一个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
@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");
}
}
<?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>
<?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相关的错误。
谢谢。