2013-10-09 24 views
1

我想在GlassFish 4使用的WebSocket,但CDI似乎对于WebSocket的不起作用。GlassFIsh4无法注入的WebSocket端点

@ServerEndpoint("/websocket") 
public class WebSocket { 

    @Inject 
    private TestBean bean; 

    ...... 
} 

bean永远是null

我已搜查谷歌,并找到了一些人说的是同一件事,但诺姆的解决方案可以帮助。

回答

2

我有这个确切的情况在工作:

https://github.com/arun-gupta/javaee7-samples/tree/master/websocket/injection

什么是你的beans.xml豆发现模式?它应该看起来像:

<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"> 

+0

我发现它后,它应该是'all',THX – bjgoblige