3 Replies Latest reply on Jul 13, 2015 8:13 PM by mazz

    @Inject dependency injection into WebSocket @ServerEndpoint

    Mark Addy Newbie

      Hi,

       

      Can't seem to get this to work, the injected reference is always null. 

       

      {code}

      @ServerEndpoint("/websocket")

      public class WebSocketEndpoint implements Serializable {

       

           @Inject

           private TestEJB testEJB;

       

      }

      {code}

       

      Is this missing or should it work, the specification implies it should be available:

       

      7.1.1

      Websocket Endpoints and Dependency Injection

      Websocket endpoints running in the Java EE platform must have full dependency injection support as de-

      scribed in the CDI specification [7] Websocket implementations part of the Java EE platform are required to

      support field, method, and constructor injection using the javax.inject.Inject annotation into all websocket

      endpoint classes, as well as the use of interceptors for these classes. [WSC-7.1.1-1]The details of this re-

      quirement are laid out in the Java EE Platform Specification [8], section EE.5.2.5, and a useful guide for

      implementations to meet the requirement is location in section EE.5.24.

       

      Cheers