2013-10-09 47 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